summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve/widget/selectw.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2026-01-07 22:58:33 +0100
committerUros Majstorovic <majstor@majstor.org>2026-01-07 22:58:33 +0100
commit46b08fc235f3f068034355970697acc0956e5c99 (patch)
tree96e2bde5d95c295a57afae353684a25544fb09fa /fw/fe310/eos/eve/widget/selectw.c
parent285ddd410a559449b7e2cbab9b2b10e850efbd08 (diff)
introduced EOSMessage struct for SPI and Event queue messages; added APP <-> FE310 bridge SPI messages; LCD/touch panel driver for app module; save relevant state to AON module before sleep;
Diffstat (limited to 'fw/fe310/eos/eve/widget/selectw.c')
-rw-r--r--fw/fe310/eos/eve/widget/selectw.c113
1 files changed, 54 insertions, 59 deletions
diff --git a/fw/fe310/eos/eve/widget/selectw.c b/fw/fe310/eos/eve/widget/selectw.c
index c0e2bfe..ee924c7 100644
--- a/fw/fe310/eos/eve/widget/selectw.c
+++ b/fw/fe310/eos/eve/widget/selectw.c
@@ -14,44 +14,42 @@
#define DIVC(x,y) ((x) / (y) + ((x) % (y) != 0))
-static int selectw_verify(utf8_t *option, uint16_t option_size, EVEFont *font, size_t *_o_len) {
- size_t o_len;
- uint16_t o_curr;
+static int selectw_verify(utf8_t *option, uint16_t option_size, EVEFont *font, size_t *len) {
+ size_t _len, curr;
int rv;
- o_curr = 0;
- while (o_curr < option_size) {
- rv = eve_font_verify(font, option + o_curr, option_size - o_curr, NULL, &o_len);
+ curr = 0;
+ while (curr < option_size) {
+ rv = eve_font_verify(font, option + curr, option_size - curr, NULL, &_len);
if (rv) {
- if (_o_len) *_o_len = o_curr;
+ if (len) *len = curr;
return rv;
}
- o_curr += o_len + 1;
- if (o_len == 0) {
- if (_o_len) *_o_len = o_curr;
+ curr += _len + 1;
+ if (_len == 0) {
+ if (len) *len = curr;
return EVE_OK;
}
}
- if (_o_len) *_o_len = o_curr;
+ if (len) *len = curr;
return EVE_OK;
}
static int selectw_count(EVESelectWidget *widget) {
- int o_len;
- int o_curr;
+ size_t len, curr;
int i;
- o_curr = 0;
+ curr = 0;
i = 0;
do {
- o_len = strnlen(widget->option + o_curr, widget->option_size - o_curr);
- if (o_len == widget->option_size - o_curr) return i;
- if (o_len) {
- o_curr += o_len + 1;
+ len = strnlen(widget->option + curr, widget->option_size - curr);
+ if (len == widget->option_size - curr) return i;
+ if (len) {
+ curr += len + 1;
i++;
}
- } while (o_len);
+ } while (len);
return i;
}
@@ -124,11 +122,10 @@ void eve_selectw_destroy(EVEWidget *_widget) {
uint8_t eve_selectw_draw(EVEWidget *_widget, uint8_t tag0) {
EVESelectWidget *widget = (EVESelectWidget *)_widget;
EVEPage *page = _widget->page;
- int o_len;
- int o_curr;
- int i, s;
+ size_t len, curr;
int16_t x1, x2, y1, y2;
uint16_t new_h;
+ int i, s;
int line0, lineN;
@@ -143,11 +140,11 @@ uint8_t eve_selectw_draw(EVEWidget *_widget, uint8_t tag0) {
_widget->tagN = tag0;
widget->line0 = line0;
- o_curr = 0;
+ curr = 0;
i = 0;
do {
- o_len = strnlen(widget->option + o_curr, widget->option_size - o_curr);
- if (!o_len || (o_len == widget->option_size - o_curr)) break;
+ len = strnlen(widget->option + curr, widget->option_size - curr);
+ if (!len || (len == widget->option_size - curr)) break;
if ((i >= line0) && (i < lineN)) {
if (_widget->tagN != EVE_NOTAG) {
eve_cmd_dl(TAG(_widget->tagN));
@@ -170,13 +167,13 @@ uint8_t eve_selectw_draw(EVEWidget *_widget, uint8_t tag0) {
}
eve_cmd_dl(END());
if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_bg));
- eve_cmd(CMD_TEXT, "hhhhs", x1, y1, widget->font->id, 0, widget->option + o_curr);
+ eve_cmd(CMD_TEXT, "hhhhs", x1, y1, widget->font->id, 0, widget->option + curr);
if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_fg));
}
- o_curr += o_len + 1;
+ curr += len + 1;
i++;
- } while (o_len);
+ } while (len);
return _widget->tagN;
}
@@ -216,19 +213,18 @@ int eve_selectw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
}
utf8_t *eve_selectw_option(EVESelectWidget *widget, int idx) {
- int o_len;
- int o_curr;
+ size_t len, curr;
int i;
- o_curr = 0;
+ curr = 0;
i = 0;
do {
- o_len = strnlen(widget->option + o_curr, widget->option_size - o_curr);
- if (o_len == widget->option_size - o_curr) return NULL;
- if (o_len && (i == idx)) return widget->option + o_curr;
- o_curr += o_len + 1;
+ len = strnlen(widget->option + curr, widget->option_size - curr);
+ if (len == widget->option_size - curr) return NULL;
+ if (len && (i == idx)) return widget->option + curr;
+ curr += len + 1;
i++;
- } while (o_len);
+ } while (len);
return NULL;
}
@@ -239,26 +235,25 @@ utf8_t *eve_selectw_option_selected(EVESelectWidget *widget) {
}
int eve_selectw_add_option(EVESelectWidget *widget, utf8_t *option) {
- int o_len;
- int o_curr;
+ size_t len, curr;
int rv, i;
rv = eve_font_verify(widget->font, option, 0, NULL, NULL);
if (rv) return rv;
- o_curr = 0;
+ curr = 0;
i = 0;
do {
- o_len = strnlen(widget->option + o_curr, widget->option_size - o_curr);
- if (o_len == widget->option_size - o_curr) return EVE_ERR_FULL;
- if (o_len) {
- o_curr += o_len + 1;
+ len = strnlen(widget->option + curr, widget->option_size - curr);
+ if (len == widget->option_size - curr) return EVE_ERR_FULL;
+ if (len) {
+ curr += len + 1;
i++;
}
- } while (o_len);
+ } while (len);
- if (o_curr + strlen(option) + 1 > widget->option_size) return EVE_ERR_FULL;
- strcpy(widget->option + o_curr, option);
+ if (curr + strlen(option) + 1 > widget->option_size) return EVE_ERR_FULL;
+ strcpy(widget->option + curr, option);
widget->option_count = i + 1;
selectw_update_sz(widget, 1);
@@ -266,16 +261,16 @@ int eve_selectw_add_option(EVESelectWidget *widget, utf8_t *option) {
return EVE_OK;
}
-int eve_selectw_set_option(EVESelectWidget *widget, utf8_t *option, uint16_t option_size) {
+int eve_selectw_set_option(EVESelectWidget *widget, utf8_t *option, uint16_t len) {
int rv, i;
- if (option_size > widget->option_size) return EVE_ERR_FULL;
+ if (len > widget->option_size) return EVE_ERR_FULL;
- rv = selectw_verify(option, option_size, widget->font, NULL);
+ rv = selectw_verify(option, len, widget->font, NULL);
if (rv) return rv;
- memcpy(widget->option, option, option_size);
- memset(widget->option + option_size, 0, widget->option_size - option_size);
+ memcpy(widget->option, option, len);
+ memset(widget->option + len, 0, widget->option_size - len);
widget->option_count = selectw_count(widget);
selectw_update_sz(widget, 1);
@@ -283,22 +278,22 @@ int eve_selectw_set_option(EVESelectWidget *widget, utf8_t *option, uint16_t opt
return EVE_OK;
}
-void eve_selectw_fix_option(EVESelectWidget *widget, utf8_t *option, uint16_t option_size) {
+void eve_selectw_fix_option(EVESelectWidget *widget, utf8_t *option, uint16_t len) {
size_t good_l, bad_l;
int rv;
do {
- rv = selectw_verify(option, option_size, widget->font, &good_l);
+ rv = selectw_verify(option, len, widget->font, &good_l);
if (rv == EVE_OK) return;
option += good_l;
- option_size -= good_l;
+ len -= good_l;
- bad_l = strnlen(option, option_size);
- if (bad_l != option_size) {
+ bad_l = strnlen(option, len);
+ if (bad_l != len) {
bad_l++;
}
- memmove(option, option + bad_l, option_size - bad_l);
- memset(option + option_size - bad_l, 0, bad_l);
- } while (bad_l != option_size);
+ memmove(option, option + bad_l, len - bad_l);
+ memset(option + len - bad_l, 0, bad_l);
+ } while (bad_l != len);
}