Skip to content

Commit

Permalink
Signal Generator app: UI update
Browse files Browse the repository at this point in the history
OFW PR 1829 by nminaylov
  • Loading branch information
xMasterX committed Oct 4, 2022
1 parent 96502e2 commit a37b0d4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#include "../signal_gen_app_i.h"

typedef enum {
LineIndexPin,
LineIndexSource,
LineIndexDivision,
} LineIndex;

static const char* const mco_pin_names[] = {
"13(Tx)",
};

static const char* const mco_source_names[] = {
"32768",
"32768Hz",
"64MHz",
"~100K",
"~200K",
Expand Down Expand Up @@ -81,14 +86,22 @@ void signal_gen_scene_mco_on_enter(void* context) {

VariableItem* item;

item = variable_item_list_add(var_item_list, "GPIO Pin", COUNT_OF(mco_pin_names), NULL, NULL);
variable_item_set_current_value_index(item, 0);
variable_item_set_current_value_text(item, mco_pin_names[0]);

item = variable_item_list_add(
var_item_list, "Source", COUNT_OF(mco_source_names), mco_source_list_change_callback, app);
var_item_list,
"Frequency",
COUNT_OF(mco_source_names),
mco_source_list_change_callback,
app);
variable_item_set_current_value_index(item, 0);
variable_item_set_current_value_text(item, mco_source_names[0]);

item = variable_item_list_add(
var_item_list,
"Division",
"Freq. divider",
COUNT_OF(mco_divisor_names),
mco_divisor_list_change_callback,
app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ void signal_gen_scene_start_on_enter(void* context) {
Submenu* submenu = app->submenu;

submenu_add_item(
submenu, "PWM", SubmenuIndexPwm, signal_gen_scene_start_submenu_callback, app);
submenu, "PWM Generator", SubmenuIndexPwm, signal_gen_scene_start_submenu_callback, app);
submenu_add_item(
submenu,
"Clock Output",
"Clock Generator",
SubmenuIndexClockOutput,
signal_gen_scene_start_submenu_callback,
app);
Expand Down
14 changes: 7 additions & 7 deletions applications/plugins/signal_generator/views/signal_gen_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef enum {
LineIndexTotalCount
} LineIndex;

static const char* const pwm_ch_names[] = {"TIM1(2)", "LPTIM2(4)"};
static const char* const pwm_ch_names[] = {"2(A7)", "4(A4)"};

struct SignalGenPwm {
View* view;
Expand All @@ -31,8 +31,8 @@ typedef struct {
#define ITEM_H 64 / 3
#define ITEM_W 128

#define VALUE_X 95
#define VALUE_W 55
#define VALUE_X 100
#define VALUE_W 45

#define FREQ_VALUE_X 62
#define FREQ_MAX 1000000UL
Expand Down Expand Up @@ -126,11 +126,11 @@ static void signal_gen_pwm_draw_callback(Canvas* canvas, void* _model) {

for(uint8_t line = 0; line < LineIndexTotalCount; line++) {
if(line == LineIndexChannel) {
line_label = "PWM Channel";
line_label = "GPIO Pin";
} else if(line == LineIndexFrequency) {
line_label = "Frequency";
} else if(line == LineIndexDuty) {
line_label = "Duty Cycle";
line_label = "Pulse width";
}

canvas_set_color(canvas, ColorBlack);
Expand Down Expand Up @@ -162,9 +162,9 @@ static void signal_gen_pwm_draw_callback(Canvas* canvas, void* _model) {
canvas_set_font(canvas, FontSecondary);

if(model->edit_mode) {
uint8_t icon_x = (FREQ_VALUE_X - 1) + (FREQ_DIGITS_NB - model->edit_digit - 1) * 6;
uint8_t icon_x = (FREQ_VALUE_X) + (FREQ_DIGITS_NB - model->edit_digit - 1) * 6;
canvas_draw_icon(canvas, icon_x, text_y - 9, &I_SmallArrowUp_4x7);
canvas_draw_icon(canvas, icon_x, text_y + 4, &I_SmallArrowDown_4x7);
canvas_draw_icon(canvas, icon_x, text_y + 5, &I_SmallArrowDown_4x7);
}
} else if(line == LineIndexDuty) {
snprintf(val_text, sizeof(val_text), "%d%%", model->duty);
Expand Down
Binary file modified assets/icons/Interface/SmallArrowDown_4x7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icons/Interface/SmallArrowUp_4x7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a37b0d4

Please sign in to comment.