./fbt format

This commit is contained in:
RogueMaster
2022-09-21 14:28:03 -04:00
parent 3f3258d9f3
commit 32e18d5500
37 changed files with 2764 additions and 2572 deletions

View File

@@ -22,29 +22,27 @@
#include "hal.h"
/* SEG -> LCD mapping */
static u8_t seg_pos[40] = {0, 1, 2, 3, 4, 5, 6, 7, 32, 8, 9, 10, 11, 12 ,13 ,14, 15, 33, 34, 35, 31, 30, 29, 28, 27, 26, 25, 24, 36, 23, 22, 21, 20, 19, 18, 17, 16, 37, 38, 39};
static u8_t seg_pos[40] = {0, 1, 2, 3, 4, 5, 6, 7, 32, 8, 9, 10, 11, 12,
13, 14, 15, 33, 34, 35, 31, 30, 29, 28, 27, 26, 25, 24,
36, 23, 22, 21, 20, 19, 18, 17, 16, 37, 38, 39};
bool_t hw_init(void) {
/* Buttons are active LOW */
cpu_set_input_pin(PIN_K00, PIN_STATE_HIGH);
cpu_set_input_pin(PIN_K01, PIN_STATE_HIGH);
cpu_set_input_pin(PIN_K02, PIN_STATE_HIGH);
bool_t hw_init(void)
{
/* Buttons are active LOW */
cpu_set_input_pin(PIN_K00, PIN_STATE_HIGH);
cpu_set_input_pin(PIN_K01, PIN_STATE_HIGH);
cpu_set_input_pin(PIN_K02, PIN_STATE_HIGH);
return 0;
return 0;
}
void hw_release(void)
{
void hw_release(void) {
}
void hw_set_lcd_pin(u8_t seg, u8_t com, u8_t val)
{
if (seg_pos[seg] < LCD_WIDTH) {
g_hal->set_lcd_matrix(seg_pos[seg], com, val);
} else {
/*
void hw_set_lcd_pin(u8_t seg, u8_t com, u8_t val) {
if(seg_pos[seg] < LCD_WIDTH) {
g_hal->set_lcd_matrix(seg_pos[seg], com, val);
} else {
/*
* IC n -> seg-com|...
* IC 0 -> 8-0 |18-3 |19-2
* IC 1 -> 8-1 |17-0 |19-3
@@ -55,85 +53,82 @@ void hw_set_lcd_pin(u8_t seg, u8_t com, u8_t val)
* IC 6 -> 28-14|37-15|39-12
* IC 7 -> 28-15|38-12|39-13
*/
if (seg == 8 && com < 4) {
g_hal->set_lcd_icon(com, val);
} else if (seg == 28 && com >= 12) {
g_hal->set_lcd_icon(com - 8, val);
}
}
if(seg == 8 && com < 4) {
g_hal->set_lcd_icon(com, val);
} else if(seg == 28 && com >= 12) {
g_hal->set_lcd_icon(com - 8, val);
}
}
}
void hw_set_button(button_t btn, btn_state_t state)
{
pin_state_t pin_state = (state == BTN_STATE_PRESSED) ? PIN_STATE_LOW : PIN_STATE_HIGH;
void hw_set_button(button_t btn, btn_state_t state) {
pin_state_t pin_state = (state == BTN_STATE_PRESSED) ? PIN_STATE_LOW : PIN_STATE_HIGH;
switch (btn) {
case BTN_LEFT:
cpu_set_input_pin(PIN_K02, pin_state);
break;
switch(btn) {
case BTN_LEFT:
cpu_set_input_pin(PIN_K02, pin_state);
break;
case BTN_MIDDLE:
cpu_set_input_pin(PIN_K01, pin_state);
break;
case BTN_MIDDLE:
cpu_set_input_pin(PIN_K01, pin_state);
break;
case BTN_RIGHT:
cpu_set_input_pin(PIN_K00, pin_state);
break;
}
case BTN_RIGHT:
cpu_set_input_pin(PIN_K00, pin_state);
break;
}
}
void hw_set_buzzer_freq(u4_t freq)
{
u32_t snd_freq = 0;
void hw_set_buzzer_freq(u4_t freq) {
u32_t snd_freq = 0;
switch (freq) {
case 0:
/* 4096.0 Hz */
snd_freq = 40960;
break;
switch(freq) {
case 0:
/* 4096.0 Hz */
snd_freq = 40960;
break;
case 1:
/* 3276.8 Hz */
snd_freq = 32768;
break;
case 1:
/* 3276.8 Hz */
snd_freq = 32768;
break;
case 2:
/* 2730.7 Hz */
snd_freq = 27307;
break;
case 2:
/* 2730.7 Hz */
snd_freq = 27307;
break;
case 3:
/* 2340.6 Hz */
snd_freq = 23406;
break;
case 3:
/* 2340.6 Hz */
snd_freq = 23406;
break;
case 4:
/* 2048.0 Hz */
snd_freq = 20480;
break;
case 4:
/* 2048.0 Hz */
snd_freq = 20480;
break;
case 5:
/* 1638.4 Hz */
snd_freq = 16384;
break;
case 5:
/* 1638.4 Hz */
snd_freq = 16384;
break;
case 6:
/* 1365.3 Hz */
snd_freq = 13653;
break;
case 6:
/* 1365.3 Hz */
snd_freq = 13653;
break;
case 7:
/* 1170.3 Hz */
snd_freq = 11703;
break;
}
case 7:
/* 1170.3 Hz */
snd_freq = 11703;
break;
}
if (snd_freq != 0) {
g_hal->set_frequency(snd_freq);
}
if(snd_freq != 0) {
g_hal->set_frequency(snd_freq);
}
}
void hw_enable_buzzer(bool_t en)
{
g_hal->play_frequency(en);
void hw_enable_buzzer(bool_t en) {
g_hal->play_frequency(en);
}