diff --git a/due_obd2/due_obd2.ino b/due_obd2/due_obd2.ino index c99bc5d..2caffe7 100644 --- a/due_obd2/due_obd2.ino +++ b/due_obd2/due_obd2.ino @@ -32,7 +32,8 @@ Program to create a car monitor display using: #define FLAG_INIT_CLEAR_POS 0x02 #define FLAG_INIT_UPDATE_PERCENT_POS 0x03 #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_MAX_POS_Y 124 @@ -41,8 +42,7 @@ Program to create a car monitor display using: #define LOGO_TEXT_WIDTH 16 #define RAM_AMOUNT_KB 96 -#define DEV_CPU_RAM_TEXT_LENGTH 3 -#define DEV_DISPLAY_TEXT_LENGTH 7 +#define DEV_LABEL_LENGTH 10 enum DeviceLabel { @@ -59,7 +59,7 @@ extern uint8_t OCR_A_Extended_M[]; /* display strings */ 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 display_size_text[] PROGMEM = "480x320"; @@ -82,7 +82,7 @@ char logo_flag = 0; /* device info variables */ char init_device_info = 0; /* wether we are drawing CPU (0), RAM (1) or DISPLAY (2) */ char ram_kb_amount = 0; /* counts up to 96 to show the KB of ram */ -char device_label_i = -1; /* counter in the current device label */ +char device_label_i = -1; /* counter in the current device label */ void on_init_enter(); void on_init_run(); @@ -172,11 +172,20 @@ void on_init_run() if (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]; - display.setColor(VGA_AQUA); - int x_position = 10 + (device_label_i * display.getFontXsize()); - display.print(text_temp, x_position, 10 + (init_device_info * display.getFontYsize() + 3)); + 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); + text_temp[0] = device_labels[init_device_info][device_label_i]; + display.setColor(VGA_AQUA); + int x_position = 10 + (device_label_i * display.getFontXsize()); + display.print(text_temp, x_position, 10 + (init_device_info * display.getFontYsize() + 3)); + } } logo_pos_i += 3; @@ -243,40 +252,56 @@ void update_percent_test() init_percent = 0; } 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() { - switch (init_device_info) + if (init_flag & (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS)) { - case DEV_CPU: - device_label_i++; - if (device_label_i > DEV_CPU_RAM_TEXT_LENGTH) - { - init_device_info++; - device_label_i = 0; - } - break; - case DEV_RAM: - device_label_i++; - if (device_label_i > DEV_CPU_RAM_TEXT_LENGTH) - { - init_device_info++; - device_label_i = 0; - } - break; - case DEV_DISPLAY: - device_label_i++; - if (device_label_i > DEV_DISPLAY_TEXT_LENGTH) - { - - device_label_i = 0; - } - break; - default: - break; + /* update device label values */ + } + else + { + /* update device labels */ + switch (init_device_info) + { + case DEV_CPU: + device_label_i++; + if (device_label_i > DEV_LABEL_LENGTH) + { + init_device_info++; + device_label_i = 0; + // init_flag |= (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS); + } + break; + case DEV_RAM: + device_label_i++; + if (device_label_i > DEV_LABEL_LENGTH) + { + init_device_info++; + device_label_i = 0; + // init_flag |= (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS); + } + break; + case DEV_DISPLAY: + device_label_i++; + if (device_label_i > DEV_LABEL_LENGTH) + { + device_label_i = 0; + // init_flag |= (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS); + } + break; + default: + break; + } + init_flag |= (1 << FLAG_DEVICE_LABEL_UPDATE_POS); } - init_flag |= (1 << FLAG_DEVICE_LABEL_UPDATE_POS); } void setup()