Added device labels. Next is adding device label values. This can be done when updating the initialisation percentage. This will then not be removed later. Use separate flag for updating KB of ram

This commit is contained in:
Sem van der Hoeven
2023-12-10 00:42:32 +01:00
parent c4df0a2302
commit 30f5af3a77

View File

@@ -32,7 +32,8 @@ Program to create a car monitor display using:
#define FLAG_INIT_CLEAR_POS 0x02 #define FLAG_INIT_CLEAR_POS 0x02
#define FLAG_INIT_UPDATE_PERCENT_POS 0x03 #define FLAG_INIT_UPDATE_PERCENT_POS 0x03
#define FLAG_DEVICE_LABEL_UPDATE_POS 0x04 #define FLAG_DEVICE_LABEL_UPDATE_POS 0x04
#define FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS 0x05 #define FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS 0x05 /* 0 if label should be updated, 1 if valyue should be updated */
#define FLAG_DEVICE_LABEL_UPDATE_KB_POS 0x06 /* count KB up */
#define LOGO_MIN_STEP 20 #define LOGO_MIN_STEP 20
#define LOGO_MAX_POS_Y 124 #define LOGO_MAX_POS_Y 124
@@ -41,8 +42,7 @@ Program to create a car monitor display using:
#define LOGO_TEXT_WIDTH 16 #define LOGO_TEXT_WIDTH 16
#define RAM_AMOUNT_KB 96 #define RAM_AMOUNT_KB 96
#define DEV_CPU_RAM_TEXT_LENGTH 3 #define DEV_LABEL_LENGTH 10
#define DEV_DISPLAY_TEXT_LENGTH 7
enum DeviceLabel enum DeviceLabel
{ {
@@ -59,7 +59,7 @@ extern uint8_t OCR_A_Extended_M[];
/* display strings */ /* display strings */
char init_text[] PROGMEM = "Initialising..."; char init_text[] PROGMEM = "Initialising...";
char device_labels[3][10] PROGMEM = {"CPU ", "RAM ", "DISPLAY"}; char device_labels[3][11] PROGMEM = {"CPU : ", "RAM : ", "DISPLAY : "};
char cpu_text[] PROGMEM = "ATSAM3X8E"; char cpu_text[] PROGMEM = "ATSAM3X8E";
char display_size_text[] PROGMEM = "480x320"; char display_size_text[] PROGMEM = "480x320";
@@ -172,12 +172,21 @@ void on_init_run()
if (init_flag & (1 << FLAG_DEVICE_LABEL_UPDATE_POS)) if (init_flag & (1 << FLAG_DEVICE_LABEL_UPDATE_POS))
{ {
if (init_flag & (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS))
{
/* draw device label values*/
display.setColor(VGA_FUCHSIA);
}
else
{
/* draw device labels */
init_flag &= ~(1 << FLAG_DEVICE_LABEL_UPDATE_POS); init_flag &= ~(1 << FLAG_DEVICE_LABEL_UPDATE_POS);
text_temp[0] = device_labels[init_device_info][device_label_i]; text_temp[0] = device_labels[init_device_info][device_label_i];
display.setColor(VGA_AQUA); display.setColor(VGA_AQUA);
int x_position = 10 + (device_label_i * display.getFontXsize()); int x_position = 10 + (device_label_i * display.getFontXsize());
display.print(text_temp, x_position, 10 + (init_device_info * display.getFontYsize() + 3)); display.print(text_temp, x_position, 10 + (init_device_info * display.getFontYsize() + 3));
} }
}
logo_pos_i += 3; logo_pos_i += 3;
last_logo_pos_y = logo_pos_y; last_logo_pos_y = logo_pos_y;
@@ -243,34 +252,49 @@ void update_percent_test()
init_percent = 0; init_percent = 0;
} }
init_flag |= (1 << FLAG_INIT_UPDATE_PERCENT_POS); init_flag |= (1 << FLAG_INIT_UPDATE_PERCENT_POS);
/* count KB up */
if (init_device_info == DEV_RAM && (0 == (init_flag & (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS))))
{
}
} }
void update_device_info() void update_device_info()
{ {
if (init_flag & (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS))
{
/* update device label values */
}
else
{
/* update device labels */
switch (init_device_info) switch (init_device_info)
{ {
case DEV_CPU: case DEV_CPU:
device_label_i++; device_label_i++;
if (device_label_i > DEV_CPU_RAM_TEXT_LENGTH) if (device_label_i > DEV_LABEL_LENGTH)
{ {
init_device_info++; init_device_info++;
device_label_i = 0; device_label_i = 0;
// init_flag |= (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS);
} }
break; break;
case DEV_RAM: case DEV_RAM:
device_label_i++; device_label_i++;
if (device_label_i > DEV_CPU_RAM_TEXT_LENGTH) if (device_label_i > DEV_LABEL_LENGTH)
{ {
init_device_info++; init_device_info++;
device_label_i = 0; device_label_i = 0;
// init_flag |= (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS);
} }
break; break;
case DEV_DISPLAY: case DEV_DISPLAY:
device_label_i++; device_label_i++;
if (device_label_i > DEV_DISPLAY_TEXT_LENGTH) if (device_label_i > DEV_LABEL_LENGTH)
{ {
device_label_i = 0; device_label_i = 0;
// init_flag |= (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS);
} }
break; break;
default: default:
@@ -278,6 +302,7 @@ void update_device_info()
} }
init_flag |= (1 << FLAG_DEVICE_LABEL_UPDATE_POS); init_flag |= (1 << FLAG_DEVICE_LABEL_UPDATE_POS);
} }
}
void setup() void setup()
{ {