fix buttons working, add basic brightness control
This commit is contained in:
parent
fe169b64f6
commit
b2de3abe08
@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include "driver/aw20xxx.h"
|
||||
|
||||
|
||||
|
||||
@ -21,6 +22,8 @@ typedef struct LedMap {
|
||||
|
||||
|
||||
|
||||
extern AW20x awled;
|
||||
|
||||
extern LedMap led_set;
|
||||
extern uint8_t awled_fade[6*12];
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include "led/ledprog.h"
|
||||
|
||||
#include "ui/btn.h"
|
||||
#include "ui/temp_ui.h"
|
||||
|
||||
/*
|
||||
*@Note
|
||||
@ -162,6 +163,9 @@ int main(void)
|
||||
// set up accelerometer
|
||||
spim_init();
|
||||
|
||||
// set up user interface
|
||||
tempui_init();
|
||||
|
||||
// configure AWU to provide ~997Hz wakeup interrupt for main program
|
||||
// TODO: confirm if the counter is reset / preloaded
|
||||
awu_init();
|
||||
|
||||
@ -62,18 +62,18 @@ void btn_process()
|
||||
btn[i].hold++;
|
||||
|
||||
if (btn[i].hold == DEBOUNCE) {
|
||||
btn_state[1] |= (1 << (i + 3));
|
||||
btn_state[1] |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
// is held?
|
||||
if (btn[i].hold == HOLD_COUNTS) {
|
||||
btn_state[2] |= (1 << (i + 3));
|
||||
btn_state[2] |= (1 << i);
|
||||
}
|
||||
|
||||
// is repeated?
|
||||
if (btn[i].repeat && (btn[i].hold == (HOLD_COUNTS + btn[i].repeat))) {
|
||||
btn_state[2] |= (1 << (i + 3));
|
||||
btn_state[2] |= (1 << i);
|
||||
btn[i].hold = HOLD_COUNTS;
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ void btn_process()
|
||||
if (!x) {
|
||||
if (btn[i].hold) {
|
||||
btn[i].hold = 0;
|
||||
btn_state[3] |= (1 << (i + 3));
|
||||
btn_state[3] |= (1 << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
43
firmware/app/ui/temp_ui.c
Normal file
43
firmware/app/ui/temp_ui.c
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* temp_ui.c: temporary ui shit until I can write something better
|
||||
*/
|
||||
|
||||
#include "ch32x035_conf.h"
|
||||
#include "btn.h"
|
||||
|
||||
#include "led/matrix.h"
|
||||
|
||||
|
||||
|
||||
static uint32_t brt = 28;
|
||||
|
||||
|
||||
|
||||
void brt_set(uint8_t idx)
|
||||
{
|
||||
switch (idx) {
|
||||
case 1: {
|
||||
if (brt > 4)
|
||||
brt--;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
brt++;
|
||||
if (brt > 44) brt = 44;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
aw20x_set_dim_global(&awled, brt);
|
||||
}
|
||||
|
||||
void tempui_init()
|
||||
{
|
||||
btn[2].cb_push = brt_set;
|
||||
btn[2].cb_hold = brt_set;
|
||||
btn[2].repeat = 200;
|
||||
|
||||
btn[1].cb_push = brt_set;
|
||||
btn[1].cb_hold = brt_set;
|
||||
btn[1].repeat = 200;
|
||||
}
|
||||
1
firmware/app/ui/temp_ui.h
Normal file
1
firmware/app/ui/temp_ui.h
Normal file
@ -0,0 +1 @@
|
||||
void tempui_init();
|
||||
Loading…
Reference in New Issue
Block a user