added nybble infotext to rgb program hex editor, fixed color editor

This commit is contained in:
true 2024-10-26 16:51:19 -07:00
parent 5abf09b69d
commit 82c428e1b9
11 changed files with 415 additions and 119 deletions

View File

@ -1,17 +1,18 @@
Mcu Type=CH59x
Address=0x00000000
Erase All=true
Program=true
Verify=true
Reset=true
Vendor=WCH
Link=WCH-Link
Toolchain=RISC-V
Series=CH59X
RTOS=NoneOS
MCU=CH592F
Description=Website: https://www.wch.cn/products/CH592.html?\nROM(byte): 448K, SRAM(byte): 26K, CHIP PINS: 28, GPIO PORTS: 20\nCH592F integrates BLE 32-bit RISC-V microcontroller MCU, 448K ROM, 24K SRAM, low average power consumption, power-off mode is only 0.3uA. Integrate USB host and device, segment LCD driver, ADC, 4-way serial port, SPI, I2C, touch key detection module, RTC, power management, etc, provide Bluetooth protocol stack and APP support.
PeripheralVersion=1.3
Target Path=obj/nametag8_CH592.hex
Link=WCH-Link
PeripheralVersion=====1.3
Description=====Website: https://www.wch.cn/products/CH592.html?\nROM(byte): 448K, SRAM(byte): 26K, CHIP PINS: 28, GPIO PORTS: 20\nCH592F integrates BLE 32-bit RISC-V microcontroller MCU, 448K ROM, 24K SRAM, low average power consumption, power-off mode is only 0.3uA. Integrate USB host and device, segment LCD driver, ADC, 4-way serial port, SPI, I2C, touch key detection module, RTC, power management, etc, provide Bluetooth protocol stack and APP support.
Mcu Type=CH59x
Address=0x00000000
Target Path=build_softi2c\nametag8_CH592.hex
CLKSpeed=3
DebugInterfaceMode=-1
Erase All=true
Program=true
Verify=true
Reset=true
SDIPrintf=false

View File

@ -84,6 +84,14 @@ struct color_hsv hsv_out[RGBLED_COUNT];
const uint8_t rgb_str_unused[] = "Unused";
const uint8_t rgb_str_reserved[] = "Reserved";
const uint8_t rgb_str_increment[] = "Increment";
const uint8_t rgb_str_delay[] = "Delay";
const uint8_t rgb_str_brightness[] = "Brightness";
void rgbled_init()
{
volatile uint32_t x;

View File

@ -22,15 +22,28 @@
#define RGBLED_COUNT 12
#define RGB_STR_UNUSED rgb_str_unused
#define RGB_STR_RESERVED rgb_str_reserved
#define RGB_STR_INCREMENT rgb_str_increment
#define RGB_STR_DELAY rgb_str_delay
#define RGB_STR_BRIGHTNESS rgb_str_brightness
typedef struct LedProgram {
char *name;
void (*prog)(uint8_t *, uint16_t);
const uint8_t * (*edit_disp)(uint8_t); // index to menu entry
} LedProgram;
extern const uint8_t rgb_str_unused[];
extern const uint8_t rgb_str_reserved[];
extern const uint8_t rgb_str_increment[];
extern const uint8_t rgb_str_delay[];
extern const uint8_t rgb_str_brightness[];
extern const uint8_t rgb_map[RGBLED_COUNT];
extern const LedProgram rgb_pgm[6];

View File

@ -439,58 +439,7 @@ void rgb_waving(uint8_t *a, uint16_t tick)
}
}
void rgb_rainbow(uint8_t *a, uint16_t tick)
{
// 0=angle-rate, 1=bitfield, 2=timeout-set, 45=angle-work, 6=sat, 7=val
// bitfield:
// 7:4 hue angle division (360 divided by 1-6; all other values mean 1, except 0 which means no offset)
// 3
// 2
// 1
// 0 direction
uint16_t *rb_angle = (uint16_t *)&a[4];
uint16_t angle;
uint16_t hoffset;
int i;
int r;
// timeout
if (!timeout || (timeout > a[2])) {
timeout = a[2];
} else {
timeout--;
return;
}
// rainbow hue angle increment
// todo: in single mode, decrement instead if direction bit set
*rb_angle += (a[0]);
if (*rb_angle >= 0x600) *rb_angle -= 0x600;
angle = *rb_angle;
// hue offset
switch (a[1] >> 4) {
case 0: { hoffset = 0; break; } // time stands still
case 2: { hoffset = 0x4d; break; } // 0xa * 0x4d * 2 = 0x604
case 3: { hoffset = 0x33; break; } // 0xa * 0x33 * 3 = 0x5fa
case 4: { hoffset = 0x26; break; } // 0xa * 0x26 * 4 = 0x5f0
case 5: { hoffset = 0x1f; break; } // 0xa * 0x1f * 5 = 0x60e
case 6: { hoffset = 0x1a; break; } // 0xa * 0x1a * 6 = 0x618
default: { hoffset = 0x9a; break; } // 0xa * 0x9a * 1 = 0x604
}
// apply to LEDs
for (i = 0; i < RGBLED_COUNT; i++) {
r = (a[1] & 0x01) ? i : RGBLED_COUNT - 1 - i;
hsv_out[rgb_map[r]].h = angle;
hsv_out[rgb_map[r]].s = a[6];
hsv_out[rgb_map[r]].v = a[7];
angle += hoffset;
if (angle >= 0x600) angle -= 0x600;
}
}
void rgb_copmode(uint8_t *a, uint16_t tick)
{
@ -691,13 +640,16 @@ void rgb_gravitycheck(uint8_t *a, uint16_t tick)
}
void rgb_rainbow(uint8_t *a, uint16_t tick);
const uint8_t * rgb_rainbow_desc(uint8_t idx);
// implemented program table
const LedProgram rgb_pgm[6] = {
{"Solid Color", rgb_solid},
{"Flicker", rgb_flicker},
{"Circles", rgb_circles},
{"Waving", rgb_waving},
{"Rainbow", rgb_rainbow},
{"Cop Mode", rgb_copmode},
{"Solid Color", rgb_solid, 0},
{"Flicker", rgb_flicker, 0},
{"Circles", rgb_circles, 0},
{"Waving", rgb_waving, 0},
{"Rainbow", rgb_rainbow, rgb_rainbow_desc},
{"Cop Mode", rgb_copmode, 0},
};

View File

@ -0,0 +1,93 @@
/*
* rgbprog_rainbow.c
* Oct 26, 2024
*
* rgb mode has a few submodes:
* - standard rgb which shows the entire color wheel
* - split top bottom where bottom is either a mirror or a rotation of the top
*/
#include <stdint.h>
#include "rgbled.h"
static const uint8_t str_hue_angle[] = "Hue Angle";
static const uint8_t str_direction[] = "Direction";
const uint8_t * rgb_rainbow_desc(uint8_t idx)
{
switch (idx) {
case 0:
case 1: return RGB_STR_INCREMENT;
case 2: return str_hue_angle;
case 3: return str_direction;
case 4:
case 5: return RGB_STR_DELAY;
case 6:
case 7: return RGB_STR_UNUSED;
case 14:
case 15: return RGB_STR_BRIGHTNESS;
default:
return RGB_STR_RESERVED;
}
}
static uint8_t timeout;
void rgb_rainbow(uint8_t *a, uint16_t tick)
{
// 0=angle-rate, 1=bitfield, 2=timeout-set, 45=angle-work, 6=sat, 7=val
// bitfield:
// 7:4 hue angle division (360 divided by 1-6; all other values mean 1, except 0 which means no offset)
// 3
// 2
// 1
// 0 direction
uint16_t *rb_angle = (uint16_t *)&a[4];
uint16_t angle;
uint16_t hoffset;
int i;
int r;
// timeout
if (!timeout || (timeout > a[2])) {
timeout = a[2];
} else {
timeout--;
return;
}
// rainbow hue angle increment
// todo: in single mode, decrement instead if direction bit set
*rb_angle += (a[0]);
if (*rb_angle >= 0x600) *rb_angle -= 0x600;
angle = *rb_angle;
// hue offset
switch (a[1] >> 4) {
case 0: { hoffset = 0; break; } // time stands still
case 2: { hoffset = 0x4d; break; } // 0xa * 0x4d * 2 = 0x604
case 3: { hoffset = 0x33; break; } // 0xa * 0x33 * 3 = 0x5fa
case 4: { hoffset = 0x26; break; } // 0xa * 0x26 * 4 = 0x5f0
case 5: { hoffset = 0x1f; break; } // 0xa * 0x1f * 5 = 0x60e
case 6: { hoffset = 0x1a; break; } // 0xa * 0x1a * 6 = 0x618
default: { hoffset = 0x9a; break; } // 0xa * 0x9a * 1 = 0x604
}
// apply to LEDs
for (i = 0; i < RGBLED_COUNT; i++) {
r = (a[1] & 0x01) ? i : RGBLED_COUNT - 1 - i;
hsv_out[rgb_map[r]].h = angle;
hsv_out[rgb_map[r]].s = a[6];
hsv_out[rgb_map[r]].v = a[7];
angle += hoffset;
if (angle >= 0x600) angle -= 0x600;
}
}

View File

@ -73,9 +73,11 @@ uint32_t idle_time_menu;
uint32_t idle_time_still;
uint8_t idle_go_sleep;
static volatile uint8_t flags_lo = 0;
//static uint8_t flags_hi = FLAG_RESET_SYSTICK;
static uint8_t st_tick = 0; // program tick counter
static uint8_t oled_tick = 0; // oled framerate counter
@ -164,6 +166,9 @@ void oled_update_done()
sysflags |= SYS_OLED_REVERSE_CHARS;
}
// power saving
#ifdef MENU_TIMEOUT_TO_NAMETAG
// root menu idle counting
@ -257,7 +262,14 @@ void lowprio_task() {
// this is not included in cpu calcs :/
if (flags_lo & FLAG_RGBLED_RUN) {
flags_lo &= ~FLAG_RGBLED_RUN;
rgbled_runprog(st_tick);
// make sure a valid program is selected
if (uconf.ledprog_rgb_idx > (sizeof(rgb_pgm) / sizeof(rgb_pgm[0]))) {
uconf.ledprog_rgb_idx = 0;
}
// now run a program
rgbled_runprog(st_tick >> 2);
}
// drop into lower clock rate
@ -328,6 +340,8 @@ void RTC_IRQHandler(void)
if (uptime & 1) {
flags_lo |= FLAG_CH32V_RESEND_CONF;
}
idle_time_still++;
}
oled_tick++;
@ -339,13 +353,7 @@ void RTC_IRQHandler(void)
// operations
switch (st_tick & 0x3) {
case 0:
case 2: {
// make sure a valid program is selected
if (uconf.ledprog_rgb_idx > (sizeof(rgb_pgm) / sizeof(rgb_pgm[0]))) {
uconf.ledprog_rgb_idx = 0;
}
case 0: {
// send RGBLEDs, render new program
flags_lo |= FLAG_RGBLED_SEND;
flags_lo |= FLAG_RGBLED_RUN;

View File

@ -36,6 +36,7 @@ typedef struct FontTable {
extern const uint8_t font_Dialog_plain_8[];
extern const uint8_t font_Roboto_Light_11[];
extern const uint8_t font_DejaVu_Sans_Mono_Bold_11[];
extern const uint8_t font_DSEG14_Classic_18[];
extern const uint8_t font_Nimbus_Mono_L_Bold_20[];
@ -46,7 +47,7 @@ extern const uint8_t font_Crushed_25[];
extern const uint8_t font_Nimbus_Sans_L_25[];
extern const uint8_t font_Orbitron_28[];
extern const FontTable font_table[10];
extern const FontTable font_table[11];

View File

@ -213,6 +213,206 @@ const uint8_t font_Dialog_plain_8[] = {
0x00,0x00,0x04,0x01,0xDC,0x01,0x20, // 125
};
const uint8_t font_Roboto_Light_11[] = {
0x0A, // Width: 10
0x0E, // Height: 14
0x20, // First Char: 32
0x5E, // Numbers of Chars: 94
// Jump Table:
0xFF, 0xFF, 0x00, 0x03, // 32:65535
0x00, 0x00, 0x04, 0x02, // 33:0
0x00, 0x04, 0x05, 0x03, // 34:4
0x00, 0x09, 0x0C, 0x06, // 35:9
0x00, 0x15, 0x0A, 0x06, // 36:21
0x00, 0x1F, 0x10, 0x08, // 37:31
0x00, 0x2F, 0x0E, 0x07, // 38:47
0x00, 0x3D, 0x01, 0x02, // 39:61
0x00, 0x3E, 0x08, 0x04, // 40:62
0x00, 0x46, 0x06, 0x04, // 41:70
0x00, 0x4C, 0x09, 0x05, // 42:76
0x00, 0x55, 0x0B, 0x06, // 43:85
0x00, 0x60, 0x02, 0x02, // 44:96
0x00, 0x62, 0x05, 0x03, // 45:98
0x00, 0x67, 0x04, 0x03, // 46:103
0x00, 0x6B, 0x07, 0x04, // 47:107
0x00, 0x72, 0x0A, 0x06, // 48:114
0x00, 0x7C, 0x08, 0x06, // 49:124
0x00, 0x84, 0x0C, 0x06, // 50:132
0x00, 0x90, 0x0A, 0x06, // 51:144
0x00, 0x9A, 0x0C, 0x06, // 52:154
0x00, 0xA6, 0x0C, 0x06, // 53:166
0x00, 0xB2, 0x0C, 0x06, // 54:178
0x00, 0xBE, 0x0B, 0x06, // 55:190
0x00, 0xC9, 0x0C, 0x06, // 56:201
0x00, 0xD5, 0x0A, 0x06, // 57:213
0x00, 0xDF, 0x04, 0x02, // 58:223
0x00, 0xE3, 0x03, 0x02, // 59:227
0x00, 0xE6, 0x0A, 0x06, // 60:230
0x00, 0xF0, 0x0A, 0x06, // 61:240
0x00, 0xFA, 0x09, 0x06, // 62:250
0x01, 0x03, 0x09, 0x05, // 63:259
0x01, 0x0C, 0x12, 0x0A, // 64:268
0x01, 0x1E, 0x0E, 0x07, // 65:286
0x01, 0x2C, 0x0C, 0x07, // 66:300
0x01, 0x38, 0x0C, 0x07, // 67:312
0x01, 0x44, 0x0C, 0x07, // 68:324
0x01, 0x50, 0x0C, 0x06, // 69:336
0x01, 0x5C, 0x0B, 0x06, // 70:348
0x01, 0x67, 0x0E, 0x08, // 71:359
0x01, 0x75, 0x0E, 0x08, // 72:373
0x01, 0x83, 0x04, 0x03, // 73:387
0x01, 0x87, 0x0A, 0x06, // 74:391
0x01, 0x91, 0x0E, 0x07, // 75:401
0x01, 0x9F, 0x0C, 0x06, // 76:415
0x01, 0xAB, 0x12, 0x0A, // 77:427
0x01, 0xBD, 0x0E, 0x08, // 78:445
0x01, 0xCB, 0x0D, 0x07, // 79:459
0x01, 0xD8, 0x0B, 0x07, // 80:472
0x01, 0xE3, 0x0D, 0x07, // 81:483
0x01, 0xF0, 0x0E, 0x07, // 82:496
0x01, 0xFE, 0x0C, 0x07, // 83:510
0x02, 0x0A, 0x0B, 0x07, // 84:522
0x02, 0x15, 0x0C, 0x07, // 85:533
0x02, 0x21, 0x0D, 0x07, // 86:545
0x02, 0x2E, 0x13, 0x0A, // 87:558
0x02, 0x41, 0x0C, 0x07, // 88:577
0x02, 0x4D, 0x0B, 0x07, // 89:589
0x02, 0x58, 0x0C, 0x07, // 90:600
0x02, 0x64, 0x06, 0x03, // 91:612
0x02, 0x6A, 0x08, 0x04, // 92:618
0x02, 0x72, 0x04, 0x03, // 93:626
0x02, 0x76, 0x07, 0x05, // 94:630
0x02, 0x7D, 0x0A, 0x05, // 95:637
0x02, 0x87, 0x03, 0x03, // 96:647
0x02, 0x8A, 0x0A, 0x06, // 97:650
0x02, 0x94, 0x0A, 0x06, // 98:660
0x02, 0x9E, 0x0A, 0x06, // 99:670
0x02, 0xA8, 0x0A, 0x06, // 100:680
0x02, 0xB2, 0x0A, 0x06, // 101:690
0x02, 0xBC, 0x07, 0x04, // 102:700
0x02, 0xC3, 0x0A, 0x06, // 103:707
0x02, 0xCD, 0x0A, 0x06, // 104:717
0x02, 0xD7, 0x04, 0x02, // 105:727
0x02, 0xDB, 0x04, 0x03, // 106:731
0x02, 0xDF, 0x0A, 0x05, // 107:735
0x02, 0xE9, 0x04, 0x02, // 108:745
0x02, 0xED, 0x12, 0x0A, // 109:749
0x02, 0xFF, 0x0A, 0x06, // 110:767
0x03, 0x09, 0x0C, 0x06, // 111:777
0x03, 0x15, 0x0A, 0x06, // 112:789
0x03, 0x1F, 0x0A, 0x06, // 113:799
0x03, 0x29, 0x07, 0x04, // 114:809
0x03, 0x30, 0x0A, 0x06, // 115:816
0x03, 0x3A, 0x06, 0x04, // 116:826
0x03, 0x40, 0x0A, 0x06, // 117:832
0x03, 0x4A, 0x09, 0x05, // 118:842
0x03, 0x53, 0x0F, 0x08, // 119:851
0x03, 0x62, 0x0A, 0x05, // 120:866
0x03, 0x6C, 0x09, 0x05, // 121:876
0x03, 0x75, 0x0A, 0x05, // 122:885
0x03, 0x7F, 0x08, 0x04, // 123:895
0x03, 0x87, 0x04, 0x02, // 124:903
0x03, 0x8B, 0x05, 0x04, // 125:907
// Font Data:
0x00,0x00,0xF8,0x05, // 33
0x00,0x00,0x18,0x00,0x18, // 34
0x00,0x01,0x20,0x07,0xF8,0x01,0x20,0x07,0xF0,0x01,0x28,0x01, // 35
0x00,0x00,0x70,0x03,0x4C,0x0C,0x48,0x04,0xB0,0x07, // 36
0x00,0x00,0x78,0x00,0x48,0x03,0xB0,0x00,0x60,0x03,0x90,0x04,0x80,0x04,0x00,0x03, // 37
0x00,0x00,0xB0,0x07,0x48,0x04,0xC8,0x04,0x30,0x05,0x80,0x07,0x00,0x04, // 38
0x18, // 39
0x00,0x00,0xF0,0x0F,0x08,0x10,0x04,0x20, // 40
0x04,0x20,0x18,0x18,0xE0,0x07, // 41
0x10,0x00,0x60,0x00,0x78,0x00,0x50,0x00,0x20, // 42
0x80,0x00,0x80,0x00,0xF0,0x07,0x80,0x00,0x80,0x00,0x80, // 43
0x00,0x0C, // 44
0x80,0x00,0x80,0x00,0x80, // 45
0x00,0x00,0x00,0x04, // 46
0x00,0x0C,0x80,0x03,0x70,0x00,0x08, // 47
0x00,0x00,0xF0,0x03,0x08,0x04,0x08,0x04,0xF0,0x03, // 48
0x00,0x00,0x10,0x00,0x08,0x00,0xF8,0x07, // 49
0x00,0x00,0x30,0x06,0x08,0x05,0x88,0x04,0x78,0x04,0x00,0x04, // 50
0x00,0x02,0x18,0x04,0x48,0x04,0x48,0x04,0xB8,0x07, // 51
0x00,0x01,0xC0,0x01,0x20,0x01,0x10,0x01,0xF8,0x07,0x00,0x01, // 52
0x00,0x00,0x78,0x02,0x48,0x04,0x48,0x04,0xC8,0x06,0x00,0x01, // 53
0x00,0x00,0xF0,0x03,0x58,0x04,0x48,0x04,0xC0,0x07,0x00,0x01, // 54
0x08,0x00,0x08,0x04,0x08,0x03,0xC8,0x00,0x38,0x00,0x08, // 55
0x00,0x00,0xB8,0x07,0x48,0x04,0x48,0x04,0xB8,0x07,0x00,0x02, // 56
0x20,0x00,0xD8,0x00,0x88,0x04,0x88,0x04,0xF0,0x03, // 57
0x00,0x00,0x20,0x04, // 58
0x00,0x0C,0x20, // 59
0x80,0x00,0x80,0x01,0x40,0x01,0x40,0x01,0x20,0x02, // 60
0x00,0x00,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01, // 61
0x00,0x00,0x20,0x02,0x40,0x01,0x40,0x01,0x80, // 62
0x10,0x00,0x08,0x00,0x88,0x05,0x78,0x00,0x20, // 63
0x00,0x00,0xE0,0x07,0x10,0x08,0xC8,0x17,0x28,0x14,0x28,0x14,0xE8,0x17,0x10,0x04,0xF0,0x07, // 64
0x00,0x04,0xC0,0x03,0x30,0x01,0x18,0x01,0xE0,0x01,0x00,0x03,0x00,0x04, // 65
0x00,0x00,0xF8,0x07,0x48,0x04,0x48,0x04,0x48,0x04,0xB0,0x03, // 66
0x00,0x00,0xF0,0x03,0x08,0x04,0x08,0x04,0x08,0x04,0x30,0x03, // 67
0x00,0x00,0xF8,0x07,0x08,0x04,0x08,0x04,0x08,0x04,0xF0,0x03, // 68
0x00,0x00,0xF8,0x07,0x48,0x04,0x48,0x04,0x48,0x04,0x08,0x04, // 69
0x00,0x00,0xF8,0x07,0x48,0x00,0x48,0x00,0x48,0x00,0x08, // 70
0x00,0x00,0xF0,0x01,0x18,0x06,0x08,0x04,0x88,0x04,0x88,0x04,0x90,0x03, // 71
0x00,0x00,0xF8,0x07,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0xF8,0x07, // 72
0x00,0x00,0xF8,0x07, // 73
0x00,0x03,0x00,0x04,0x00,0x04,0x00,0x04,0xF8,0x03, // 74
0x00,0x00,0xF8,0x07,0x40,0x00,0xA0,0x00,0x10,0x01,0x08,0x06,0x08,0x04, // 75
0x00,0x00,0xF8,0x07,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04, // 76
0x00,0x00,0xF8,0x07,0x60,0x00,0x80,0x01,0x00,0x06,0x80,0x03,0x60,0x00,0x18,0x00,0xF8,0x07, // 77
0x00,0x00,0xF8,0x07,0x30,0x00,0x40,0x00,0x80,0x01,0x00,0x02,0xF8,0x07, // 78
0xE0,0x01,0x10,0x02,0x08,0x04,0x08,0x04,0x08,0x04,0x30,0x03,0xC0, // 79
0x00,0x00,0xF8,0x07,0x88,0x00,0x88,0x00,0x88,0x00,0xF8, // 80
0xE0,0x01,0x10,0x02,0x08,0x04,0x08,0x04,0x08,0x04,0x30,0x0B,0xC0, // 81
0x00,0x00,0xF8,0x07,0x88,0x00,0x88,0x00,0x88,0x01,0x70,0x06,0x00,0x04, // 82
0x00,0x00,0x30,0x02,0x48,0x04,0x48,0x04,0x88,0x04,0x90,0x03, // 83
0x08,0x00,0x08,0x00,0x08,0x00,0xF8,0x07,0x08,0x00,0x08, // 84
0x00,0x00,0xF8,0x03,0x00,0x04,0x00,0x04,0x00,0x04,0xF8,0x03, // 85
0x18,0x00,0xE0,0x00,0x00,0x03,0x00,0x06,0xC0,0x01,0x38,0x00,0x08, // 86
0x18,0x00,0xE0,0x01,0x00,0x06,0xC0,0x01,0x38,0x00,0x70,0x00,0x80,0x01,0x80,0x07,0x78,0x00,0x08, // 87
0x08,0x04,0x10,0x02,0x20,0x01,0xC0,0x00,0x30,0x03,0x08,0x04, // 88
0x08,0x00,0x30,0x00,0x40,0x00,0xC0,0x07,0x20,0x00,0x18, // 89
0x00,0x04,0x08,0x07,0x88,0x04,0x48,0x04,0x38,0x04,0x08,0x04, // 90
0x00,0x00,0xFC,0x1F,0x04,0x10, // 91
0x18,0x00,0x60,0x00,0x80,0x03,0x00,0x0C, // 92
0x04,0x10,0xFC,0x1F, // 93
0x00,0x00,0x70,0x00,0x18,0x00,0x60, // 94
0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08, // 95
0x00,0x00,0x0C, // 96
0x00,0x00,0xA0,0x07,0xA0,0x04,0xA0,0x04,0xC0,0x07, // 97
0x00,0x00,0xF8,0x07,0x20,0x04,0x20,0x04,0xE0,0x07, // 98
0x00,0x00,0xC0,0x03,0x20,0x04,0x20,0x04,0x60,0x06, // 99
0x00,0x00,0xE0,0x07,0x20,0x04,0x20,0x04,0xF8,0x07, // 100
0x00,0x00,0xC0,0x03,0xA0,0x04,0xA0,0x04,0xE0,0x04, // 101
0x00,0x00,0xF8,0x07,0x24,0x00,0x24, // 102
0x00,0x00,0xE0,0x17,0x20,0x14,0x20,0x14,0xE0,0x0F, // 103
0x00,0x00,0xF8,0x07,0x20,0x00,0x20,0x00,0xE0,0x07, // 104
0x00,0x00,0xE8,0x07, // 105
0x00,0x10,0xE8,0x0F, // 106
0x00,0x00,0xFC,0x07,0x80,0x01,0x40,0x02,0x20,0x04, // 107
0x00,0x00,0xFC,0x07, // 108
0x00,0x00,0xE0,0x07,0x20,0x00,0x20,0x00,0xE0,0x07,0x40,0x00,0x20,0x00,0x20,0x00,0xE0,0x07, // 109
0x00,0x00,0xE0,0x07,0x20,0x00,0x20,0x00,0xE0,0x07, // 110
0x80,0x01,0x60,0x06,0x20,0x04,0x20,0x04,0x60,0x06,0x80,0x01, // 111
0x00,0x00,0xE0,0x1F,0x20,0x04,0x20,0x04,0xE0,0x07, // 112
0x80,0x01,0x60,0x06,0x20,0x04,0x20,0x04,0xE0,0x1F, // 113
0x00,0x00,0xE0,0x07,0x20,0x00,0x20, // 114
0x00,0x00,0xE0,0x06,0xA0,0x04,0xA0,0x04,0x20,0x07, // 115
0x20,0x00,0xF0,0x03,0x20,0x04, // 116
0x00,0x00,0xE0,0x07,0x00,0x04,0x00,0x04,0xE0,0x07, // 117
0x60,0x00,0x80,0x03,0x00,0x06,0xC0,0x01,0x20, // 118
0x60,0x00,0x80,0x01,0x00,0x07,0xC0,0x00,0xE0,0x01,0x00,0x06,0xC0,0x03,0x20, // 119
0x20,0x04,0x40,0x02,0x80,0x01,0x40,0x02,0x20,0x04, // 120
0x60,0x10,0x80,0x13,0x00,0x0E,0xC0,0x01,0x20, // 121
0x00,0x04,0x20,0x06,0xA0,0x05,0x60,0x04,0x20,0x04, // 122
0x00,0x00,0xF0,0x07,0x08,0x08,0x04,0x10, // 123
0x00,0x00,0xF8,0x0F, // 124
0x04,0x10,0x78,0x0F,0x80, // 125
};
const uint8_t font_DejaVu_Sans_Mono_Bold_11[] = {
0x07, // Width: 7
0x0E, // Height: 14

View File

@ -6,10 +6,11 @@
#include "font.h"
const FontTable font_table[10] = {
const FontTable font_table[11] = {
{0, "Dialog 8", font_Dialog_plain_8},
{0, "DJVmono 11", font_DejaVu_Sans_Mono_Bold_11},
{0, "DSEG14 18", font_DSEG14_Classic_18},
{0, "RoboMono10", font_Roboto_Light_11},
{0, "DejaMono11", font_DejaVu_Sans_Mono_Bold_11},
{1, "DSEG14 18", font_DSEG14_Classic_18},
{1, "Nimbmono20", font_Nimbus_Mono_L_Bold_20},
{1, "DlgBold 24", font_DialogInput_Bold_24},
{1, "LuckestG23", font_Luckiest_Guy_23},

View File

@ -22,6 +22,15 @@
#define EDIT_MODE_IDLE 0x01
#define EDIT_MODE_EDIT 0x02
#define LI_PROGRAM_SELECT 0
#define LI_PROGRAM_EDIT 1
#define LI_FAVCOLOR_HUE 2
#define LI_FAVCOLOR_SAT 3
#define LI_FAVCOLOR_VAL 4
#define LI_ALTCOLOR_HUE 5
#define LI_ALTCOLOR_SAT 6
#define LI_ALTCOLOR_VAL 7
static uint8_t edit_mode = MENU_BTNSTYLE_MENU;
@ -45,8 +54,7 @@ static void menu_2_val_dec(uint8_t *val, uint8_t loop)
void menu_2_btn_next(uint8_t idx)
{
switch (edit_idx) {
case 1:
case 3: {
case LI_PROGRAM_EDIT: {
switch (edit_mode) {
case MENU_BTNSTYLE_PROGSIMPLE_IDLE: {
prog_data_idx++;
@ -79,20 +87,19 @@ void menu_2_btn_next(uint8_t idx)
}
break;
}
case 4: menu_2_val_inc(&uconf.favcolor_hue, 1); return;
case 5: menu_2_val_inc(&uconf.favcolor_sat, 0); return;
case 6: menu_2_val_inc(&uconf.favcolor_val, 0); return;
case 7: menu_2_val_inc(&uconf.altcolor_hue, 1); return;
case 8: menu_2_val_inc(&uconf.altcolor_sat, 0); return;
case 9: menu_2_val_inc(&uconf.altcolor_val, 0); return;
case LI_FAVCOLOR_HUE: menu_2_val_inc(&uconf.favcolor_hue, 1); return;
case LI_FAVCOLOR_SAT: menu_2_val_inc(&uconf.favcolor_sat, 0); return;
case LI_FAVCOLOR_VAL: menu_2_val_inc(&uconf.favcolor_val, 0); return;
case LI_ALTCOLOR_HUE: menu_2_val_inc(&uconf.altcolor_hue, 1); return;
case LI_ALTCOLOR_SAT: menu_2_val_inc(&uconf.altcolor_sat, 0); return;
case LI_ALTCOLOR_VAL: menu_2_val_inc(&uconf.altcolor_val, 0); return;
}
}
void menu_2_btn_prev(uint8_t idx)
{
switch (edit_idx) {
case 1:
case 3: {
case LI_PROGRAM_EDIT: {
switch (edit_mode) {
case MENU_BTNSTYLE_PROGSIMPLE_IDLE: {
if (prog_data_idx) {
@ -126,12 +133,12 @@ void menu_2_btn_prev(uint8_t idx)
}
break;
}
case 4: menu_2_val_dec(&uconf.favcolor_hue, 1); return;
case 5: menu_2_val_dec(&uconf.favcolor_sat, 0); return;
case 6: menu_2_val_dec(&uconf.favcolor_val, 0); return;
case 7: menu_2_val_dec(&uconf.altcolor_hue, 1); return;
case 8: menu_2_val_dec(&uconf.altcolor_sat, 0); return;
case 9: menu_2_val_dec(&uconf.altcolor_val, 0); return;
case LI_FAVCOLOR_HUE: menu_2_val_dec(&uconf.favcolor_hue, 1); return;
case LI_FAVCOLOR_SAT: menu_2_val_dec(&uconf.favcolor_sat, 0); return;
case LI_FAVCOLOR_VAL: menu_2_val_dec(&uconf.favcolor_val, 0); return;
case LI_ALTCOLOR_HUE: menu_2_val_dec(&uconf.altcolor_hue, 1); return;
case LI_ALTCOLOR_SAT: menu_2_val_dec(&uconf.altcolor_sat, 0); return;
case LI_ALTCOLOR_VAL: menu_2_val_dec(&uconf.altcolor_val, 0); return;
}
}
@ -234,32 +241,44 @@ void menu_2_disp(uint8_t idx)
ssd1306fb_set_cursor(10, 7);
if (idx >= 2 && idx <= 7) {
f = (idx - 4) / 3;
if (idx >= LI_FAVCOLOR_HUE && idx <= LI_ALTCOLOR_VAL) {
f = (idx - LI_FAVCOLOR_HUE) / 3;
ssd1306fb_draw_str(font_table[0].font, (f == 0) ? "Favorite " : "Alternate ", 1);
}
// which item selected?
switch (idx) {
case 0: {
ssd1306fb_draw_str(font_table[0].font, "Edge Program", 1);
case LI_PROGRAM_SELECT: {
ssd1306fb_draw_str(font_table[0].font, "RGB Program", 1);
ssd1306fb_set_cursor(16, 15);
ssd1306fb_draw_str(font_table[0].font, rgb_pgm[uconf.ledprog_rgb_idx].name, 1);
goto MENU_2_DRAW_TEXT_DONE;
}
case 1: {
case LI_PROGRAM_EDIT: {
uint8_t *s;
uint8_t *topline;
int8_t left;
sprintf(txt, "Edge");
s = uconf.ledprog_rgb_data[uconf.ledprog_rgb_idx];
if (edit_mode == MENU_BTNSTYLE_MENU) {
ssd1306fb_draw_str(font_table[0].font, txt, 1);
ssd1306fb_draw_str(font_table[0].font, " Settings", 1);
ssd1306fb_draw_str(font_table[0].font, "RGB Settings", 1);
} else {
ssd1306fb_set_cursor(48, 0);
ssd1306fb_draw_str(font_table[1].font, txt, 1);
if (rgb_pgm[uconf.ledprog_rgb_idx].edit_disp) {
topline = (uint8_t *)rgb_pgm[uconf.ledprog_rgb_idx].edit_disp(prog_data_idx);
} else {
strcpy(txt, "Hex Editor");
topline = txt;
}
w = ssd1306fb_get_str_width(font_table[1].font, topline, strlen(topline), 0);
left = (oled.width >> 1) - (w >> 1);
ssd1306fb_set_cursor(left - 4, 1);
ssd1306fb_draw_str(font_table[1].font, topline, 1);
// ssd1306fb_draw_rect(left - 2, 0, w + left + 1, 13);
}
w = 16;
@ -301,12 +320,12 @@ void menu_2_disp(uint8_t idx)
goto MENU_2_DRAW_TEXT_DONE;
}
case 2:
case 5: {
case LI_FAVCOLOR_HUE:
case LI_ALTCOLOR_HUE: {
ssd1306fb_draw_str(font_table[0].font, "Color Hue", 1);
// bar position
f = (idx == 4) ? uconf.favcolor_hue : uconf.altcolor_hue;
f = (idx == LI_FAVCOLOR_HUE) ? uconf.favcolor_hue : uconf.altcolor_hue;
// draw hue markers
ssd1306fb_draw_vline(36 + 21, 19, 21);
@ -314,21 +333,21 @@ void menu_2_disp(uint8_t idx)
goto MENU_2_EDIT_COLOR_LINE;
}
case 3:
case 6: {
case LI_FAVCOLOR_SAT:
case LI_ALTCOLOR_SAT: {
ssd1306fb_draw_str(font_table[0].font, "Color Sat.", 1);
// bar position
f = (idx == 5) ? uconf.favcolor_sat : uconf.altcolor_sat;
f = (idx == LI_FAVCOLOR_SAT) ? uconf.favcolor_sat : uconf.altcolor_sat;
goto MENU_2_PCT_COLOR_TEXT;
}
case 4:
case 7: {
case LI_FAVCOLOR_VAL:
case LI_ALTCOLOR_VAL: {
ssd1306fb_draw_str(font_table[0].font, "Color Value", 1);
// bar position
f = (idx == 6) ? uconf.favcolor_val : uconf.altcolor_val;
f = (idx == LI_FAVCOLOR_VAL) ? uconf.favcolor_val : uconf.altcolor_val;
MENU_2_PCT_COLOR_TEXT:
// percentage text
@ -352,7 +371,7 @@ MENU_2_EDIT_COLOR_LINE:
ssd1306fb_draw_line(f - 2, 16, f, 19);
if (edit_mode == MENU_BTNSTYLE_LED_EDIT) {
if (idx == 4 || idx == 7) {
if (idx == LI_FAVCOLOR_HUE || idx == LI_ALTCOLOR_HUE) {
// RGBR indicators
ssd1306fb_set_cursor(33, 21);
ssd1306fb_draw_str(font_table[0].font, "R", 0);

View File

@ -85,10 +85,10 @@ void menu_5_disp(uint8_t idx)
}
}
w = ssd1306fb_get_str_width(font_table[1].font, txt, strlen(txt), 1);
w = ssd1306fb_get_str_width(font_DejaVu_Sans_Mono_Bold_11, txt, strlen(txt), 1);
x = 68 - (w >> 1);
ssd1306fb_set_cursor(x, 18);
ssd1306fb_draw_str(font_table[1].font, txt, 1);
ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, txt, 1);
// draw box
ssd1306fb_draw_rect(x - 2, 18, x + w + 2, 31);