10 #include "avr_helper.h" 11 #include <avr/eeprom.h> 14 #include <avr/pgmspace.h> 16 #include <avr/interrupt.h> 17 #include <util/delay.h> 46 __flash
const char VOL_NAME[] =
"SENSITIVITY";
47 static __flash
const char str2[] =
"A.G.C.";
48 static __flash
const char str3[] =
"SLEEP TIME";
49 static __flash
const char str4[] =
"WS2812 IN GROUP";
50 static __flash
const char str5[] =
"GROUPS OF WS2812";
51 static __flash
const char str6[] =
"RESET TO DEFAULT";
52 static __flash
const char str7[] =
"IR REMOTE MENU";
53 static __flash
const char str8[] =
"DC OFFSET";
55 static __flash
const char ir0[] =
"POWER OFF";
56 static __flash
const char ir1[] =
"VOLUME+";
57 static __flash
const char ir2[] =
"VOLUME-";
58 static __flash
const char ir3[] =
"EFFECT NEXT";
59 static __flash
const char ir4[] =
"EFFECT PREV";
60 static __flash
const char ir5[] =
"PRESET NEXT";
61 static __flash
const char ir6[] =
"PRESET PREV";
62 static __flash
const char ir7[] =
"DONE UP LEARNING";
64 static void default_setup(
void){
72 static void default_ir_setup(
void){
74 init_ir_cmd_code(0, CMD_VOLUME_PLUS, IR_VOL_PLUS);
75 init_ir_cmd_code(1, CMD_VOLUME_MINUS, IR_VOL_MINUS);
76 init_ir_cmd_code(2, CMD_EFFECT_PLUS, IR_CH_PLUS);
77 init_ir_cmd_code(3, CMD_EFFECT_MINUS, IR_CH_MINUS);
78 init_ir_cmd_code(4, CMD_PRESET_PLUS, IR_NEXT);
79 init_ir_cmd_code(5, CMD_PRESET_MINUS, IR_PREV);
80 init_ir_cmd_code(6, CMD_POWER,
IR_NO_CMD);
88 eeprom_update_block(&cfg, &e_cfg,
sizeof(
config_t));
93 eeprom_read_block(&cfg, &e_cfg,
sizeof(
config_t));
100 cfg.dc_offset = 0x7FE0;
101 eeprom_update_block(&cfg, &e_cfg,
sizeof(
config_t));
114 #define DC_OFS_MIN 29696UL 115 #define DC_OFS_MAX 35200UL 117 static void edit_dc(int8_t d, uint16_t data){
118 uint16_t tmp = cfg.dc_offset;
120 if(tmp < DC_OFS_MIN) tmp = DC_OFS_MIN;
121 else if(tmp > DC_OFS_MAX) tmp = DC_OFS_MAX;
125 static void paint_dc(int32_t d){
134 utoa(cfg.dc_offset, tmp, 10);
139 #define ir_wait lock_current_menu_item 140 static uint32_t ir_code;
142 static void ir_paint(int32_t d){
147 if(tmp) ir_code = tmp;
152 if((++div & 0x20) && ir_wait)
155 if((ir_code == 0) || (ir_code ==
IR_NO_CMD)){
161 if(ir_wait) reset_menu_timeout();
183 static void edit_pix(int8_t d, uint16_t data){
185 int16_t tmp = *(uint8_t *)data;
191 tmp += d*STEP_GROUP_OF_PIX;
192 if(tmp < MIN_GROUP_OF_PIX) tmp = MIN_GROUP_OF_PIX;
193 if(tmp > MAX_GROUP_OF_PIX) tmp = MAX_GROUP_OF_PIX;
196 tmp += d*STEP_PIX_IN_GROUP;
197 if(tmp < MIN_PIX_IN_GROUP) tmp = MIN_PIX_IN_GROUP;
198 if(tmp > MAX_PIX_IN_GROUP) tmp = MAX_PIX_IN_GROUP;
200 *(uint8_t *)data = tmp;
207 static void paint_pix(int32_t d){
219 static __flash
const menu_item_t __flash
const ir_menu_items[] = {
220 _MI_USER(ir0, NULL, ir_paint, ir_action, CMD_POWER),
221 _MI_USER(ir1, NULL, ir_paint, ir_action, CMD_VOLUME_PLUS),
222 _MI_USER(ir2, NULL, ir_paint, ir_action, CMD_VOLUME_MINUS),
223 _MI_USER(ir3, NULL, ir_paint, ir_action, CMD_EFFECT_PLUS),
224 _MI_USER(ir4, NULL, ir_paint, ir_action, CMD_EFFECT_MINUS),
225 _MI_USER(ir5, NULL, ir_paint, ir_action, CMD_PRESET_PLUS),
226 _MI_USER(ir6, NULL, ir_paint, ir_action, CMD_PRESET_MINUS),
227 _MI_USER(ir7, NULL, show_press_encoder_msg, NULL, 0),
228 _MI_USER(str6, NULL, show_press_encoder_msg, ir_action_reset, 0)
231 static __flash
const menu_t ir_menu = _MENU(ir_menu_items);
233 static __flash
const menu_item_t __flash
const main_menu_items[] = {
237 _MI_USER(str5, edit_pix, paint_pix, update_and_reboot, &cfg.
group_of_pixels),
238 _MI_USER(str4, edit_pix, paint_pix, update_and_reboot, &cfg.
pixels_in_group),
239 _MI_USER(str8, edit_dc, paint_dc, update_and_reboot, &
music),
240 _MI_SUBMENU(str7, ir_menu),
241 _MI_USER(str6, NULL, show_press_encoder_msg, reset_to_default,0)
244 __flash
const menu_t main_menu = _MENU(main_menu_items);
#define lcd_puts_P(__s)
macros for automatically storing string constant in program memory
void lcd_gotoxy(uint8_t x, uint8_t y)
Set cursor to specified position.
#define BAND_LF
битовые маски частот спектра, объединенные в НЧ-полосу
#define BAND_HF
битовые маски частот спектра, объединенные в ВЧ-полосу
#define MAX_LEVEL
фиксированное количество уровней регулирования чувствительности
Константы команд пульта управления INCAR MP3.
signal_t music
Параметры мелодии
volume_t average_vol
средняя громкость
void lcd_clrscr(void)
Clear display and set cursor to home position.
void set_ir_cmd_code(control_cmd_t cmd, uint32_t code)
назначение команде IR-кода
Вспомогательные эффекты ЖКИ
структура конфигурации устройства
uint8_t sensitivity
уровень регулировки чувствительности
структура параметров звукового сигнала
void show_hex_long(uint32_t num)
вывод 4 байтового числа в HEX формате с лидирующими нулями
uint8_t time_to_sleep
время автоотключения
#define BAND_MF
битовые маски частот спектра, объединенные в СЧ-полосу
Аппаратно-зависимые определения
uint32_t get_ir_code(void)
получение кода ДУ
uint16_t band_mask[BAND_CNT]
битовые маски полос
uint8_t agc_enabled
АРУ включено
uint8_t pixels_in_group
количество пикселов в группе
void lcd_puts(const char *s)
Display string without auto linefeed.
#define IR_NO_CMD
Заглушка "нет команды".
uint8_t group_of_pixels
количество групп пикселов
описания модуля дистанционного управления
описания урганов управления
uint32_t get_ir_cmd_code(control_cmd_t cmd)
получение IR-кода команды
void update_config(void)
обновление EEPROM с параметрами настройки
void show_number(int32_t num)
вывод десятичного числа
uint8_t clear
признак чистых настроек