summaryrefslogtreecommitdiff
path: root/fw/fe310/phone
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/phone')
-rw-r--r--fw/fe310/phone/ecp.c2
-rw-r--r--fw/fe310/phone/phone.c120
2 files changed, 104 insertions, 18 deletions
diff --git a/fw/fe310/phone/ecp.c b/fw/fe310/phone/ecp.c
index 6ce9c8f..32c15ea 100644
--- a/fw/fe310/phone/ecp.c
+++ b/fw/fe310/phone/ecp.c
@@ -58,7 +58,7 @@ static int handle_open(ECPConnection *conn, ECP2Buffer *b) {
static ssize_t handle_msg(ECPConnection *conn, ecp_seq_t seq, unsigned char mtype, unsigned char *msg, size_t msg_size, ECP2Buffer *b) {
switch (mtype) {
case MTYPE_VOIP: {
- eos_i2s_spk_write(msg, msg_size);
+ eos_i2s_spk_write(msg, msg_size, EOS_I2S_TRANS_MONO2D);
break;
}
diff --git a/fw/fe310/phone/phone.c b/fw/fe310/phone/phone.c
index ca877e4..3af31b6 100644
--- a/fw/fe310/phone/phone.c
+++ b/fw/fe310/phone/phone.c
@@ -83,10 +83,9 @@ static void handle_cell_voice(unsigned char type, unsigned char *buffer, uint16_
phone_state = PHONE_STATE_CIP;
app_status_set_msg("CALL BEGIN");
eos_net_acquire_for_evt(EOS_EVT_I2S | EOS_I2S_ETYPE_MIC, 1);
- eos_i2s_spk_init(spk_arr, ABUF_SIZE);
- eos_i2s_mic_init(mic_arr, ABUF_SIZE);
- eos_i2s_mic_set_wm(MIC_WM);
- eos_i2s_mic_set_handler(handle_mic);
+ eos_i2s_spk_set_buf(spk_arr, ABUF_SIZE);
+ eos_i2s_mic_set_buf(mic_arr, ABUF_SIZE);
+ eos_i2s_mic_set_handler(handle_mic, MIC_WM);
eos_i2s_mic_set_vol(4);
eos_i2s_start(8000);
}
@@ -106,7 +105,7 @@ static void handle_cell_voice(unsigned char type, unsigned char *buffer, uint16_
case EOS_CELL_MTYPE_VOICE_PCM: {
if (phone_state == PHONE_STATE_CIP) {
- eos_i2s_spk_write(buffer+1, len-1);
+ eos_i2s_spk_write(buffer+1, len-1, EOS_I2S_TRANS_MONO2D);
}
break;
}
@@ -114,27 +113,89 @@ static void handle_cell_voice(unsigned char type, unsigned char *buffer, uint16_
eos_net_free(buffer, 0);
}
+#define BTN_R 50
+#define BTN_SP ((APP_SCREEN_W - 6 * BTN_R) / 4)
+#define BTN_C1 (BTN_SP + BTN_R)
+#define BTN_C2 (2 * BTN_SP + 3 * BTN_R)
+#define BTN_C3 (3 * BTN_SP + 5 * BTN_R)
+#define BTN_C4 (4 * BTN_SP + 7 * BTN_R)
+#define BTN_C5 (5 * BTN_SP + 9 * BTN_R)
+
static void widget_btn_draw(EVEFreeWidget *widget) {
EVEWidget *_widget = &widget->w;
EVEPage *page = _widget->page;
- uint8_t tag_up, tag_dn;
+ uint8_t tag0;
eve_cmd_dl(BEGIN(EVE_POINTS));
- eve_cmd_dl(POINT_SIZE((_widget->g.h / 2) * 16));
-
- tag_up = eve_freew_tag(widget);
+ eve_cmd_dl(POINT_SIZE(BTN_R * 16));
+
+ eve_cmd_dl(COLOR_RGB(0x20, 0x20, 0x20));
+ tag0 = eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C1, _widget->g.y + BTN_C2));
+ eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C2, _widget->g.y + BTN_C2));
+ eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C3, _widget->g.y + BTN_C2));
+
+ eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C1, _widget->g.y + BTN_C3));
+ eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C2, _widget->g.y + BTN_C3));
+ eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C3, _widget->g.y + BTN_C3));
+
+ eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C1, _widget->g.y + BTN_C4));
+ eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C2, _widget->g.y + BTN_C4));
+ eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C3, _widget->g.y + BTN_C4));
+
+ eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C1, _widget->g.y + BTN_C5));
+ eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C2, _widget->g.y + BTN_C5));
+ eve_freew_tag(widget);
+ eve_cmd_dl(VERTEX2F(BTN_C3, _widget->g.y + BTN_C5));
+
+ eve_freew_tag(widget);
eve_cmd_dl(COLOR_RGB(0x0, 0x255, 0x0));
- eve_cmd_dl(VERTEX2F(APP_SCREEN_W / 3, _widget->g.y + _widget->g.h / 2));
+ eve_cmd_dl(VERTEX2F(BTN_C1, _widget->g.y + BTN_C1));
- tag_dn = eve_freew_tag(widget);
+ eve_freew_tag(widget);
eve_cmd_dl(COLOR_RGB(0x255, 0x0, 0x0));
- eve_cmd_dl(VERTEX2F(APP_SCREEN_W - APP_SCREEN_W / 3, _widget->g.y + _widget->g.h / 2));
+ eve_cmd_dl(VERTEX2F(BTN_C3, _widget->g.y + BTN_C1));
eve_cmd_dl(COLOR_RGBC(page->v.color_fg));
eve_cmd_dl(END());
+
+ eve_cmd_dl(TAG(tag0));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C1, _widget->g.y + BTN_C2, app_font()->id, EVE_OPT_CENTER, "1");
+ eve_cmd_dl(TAG(tag0 + 1));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C2, _widget->g.y + BTN_C2, app_font()->id, EVE_OPT_CENTER, "2");
+ eve_cmd_dl(TAG(tag0 + 2));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C3, _widget->g.y + BTN_C2, app_font()->id, EVE_OPT_CENTER, "3");
+ eve_cmd_dl(TAG(tag0 + 3));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C1, _widget->g.y + BTN_C3, app_font()->id, EVE_OPT_CENTER, "4");
+ eve_cmd_dl(TAG(tag0 + 4));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C2, _widget->g.y + BTN_C3, app_font()->id, EVE_OPT_CENTER, "5");
+ eve_cmd_dl(TAG(tag0 + 5));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C3, _widget->g.y + BTN_C3, app_font()->id, EVE_OPT_CENTER, "6");
+ eve_cmd_dl(TAG(tag0 + 6));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C1, _widget->g.y + BTN_C4, app_font()->id, EVE_OPT_CENTER, "7");
+ eve_cmd_dl(TAG(tag0 + 7));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C2, _widget->g.y + BTN_C4, app_font()->id, EVE_OPT_CENTER, "8");
+ eve_cmd_dl(TAG(tag0 + 8));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C3, _widget->g.y + BTN_C4, app_font()->id, EVE_OPT_CENTER, "9");
+ eve_cmd_dl(TAG(tag0 + 9));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C1, _widget->g.y + BTN_C5, app_font()->id, EVE_OPT_CENTER, "*");
+ eve_cmd_dl(TAG(tag0 + 10));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C2, _widget->g.y + BTN_C5, app_font()->id, EVE_OPT_CENTER, "0");
+ eve_cmd_dl(TAG(tag0 + 11));
+ eve_cmd(CMD_TEXT, "hhhhs", BTN_C3, _widget->g.y + BTN_C5, app_font()->id, EVE_OPT_CENTER, "#");
}
-static void call(char * num) {
+static void call(char *num) {
int rv;
if (strlen(num)) {
@@ -151,7 +212,29 @@ static int widget_btn_touch(EVEFreeWidget *widget, EVETouch *touch, uint16_t evt
int rv;
tagi = eve_widget_tag_index(widget, touch->tag_up);
- if (tagi == 0) {
+ if (tagi < 12) {
+ EVEPage *page = widget->w.page;
+ EVEStrWidget *strw = (EVEStrWidget *)eve_page_widget(page, 0);
+ int ch;
+
+ if (tagi < 9) {
+ ch = '0' + tagi + 1;
+ } else {
+ switch (tagi) {
+ case 9:
+ ch = '*';
+ break;
+ case 10:
+ ch = '0';
+ break;
+ case 11:
+ ch = '#';
+ break;
+ }
+ }
+ printf("PUTC CH:%d\n", ch);
+ eve_strw_putc(strw, ch);
+ } else if (tagi == 12) {
switch (phone_state) {
case PHONE_STATE_RING: {
app_status_set_msg("ANSWER");
@@ -168,7 +251,7 @@ static int widget_btn_touch(EVEFreeWidget *widget, EVETouch *touch, uint16_t evt
break;
}
}
- } else if (tagi == 1) {
+ } else if (tagi == 13) {
if (phone_state != PHONE_STATE_IDLE) {
if (phone_state != PHONE_STATE_CIP) {
phone_state = PHONE_STATE_IDLE;
@@ -195,11 +278,11 @@ int phone_app(EVEWindow *window, EVEViewStack *stack) {
.widget.type = EVE_WIDGET_TYPE_STR,
.widget.tspec.str.str_size = EOS_CELL_MAX_DIAL_STR + 1,
},
- APP_SPACERW(APP_SCREEN_W, 50),
+ APP_SPACERW(APP_SCREEN_W, 10),
{
.widget.type = EVE_WIDGET_TYPE_FREE,
.widget.g.w = APP_SCREEN_W,
- .widget.g.h = 100,
+ .widget.g.h = APP_SCREEN_H,
.widget.tspec.free.draw = widget_btn_draw,
.widget.tspec.free.touch = widget_btn_touch,
},
@@ -210,6 +293,9 @@ int phone_app(EVEWindow *window, EVEViewStack *stack) {
APP_LOG(APP_LOG_ERR, "OUT OF MEMORY\n");
return EVE_ERR_NOMEM;
}
+ EVEStrWidget *strw = (EVEStrWidget *)eve_page_widget(page, 0);
+ strw->w.putc = NULL;
+ eve_widget_set_focus(&strw->w);
return EVE_OK;
}