2021-07-02 22:19:04 +02:00
|
|
|
#include "interface.h"
|
|
|
|
|
#include "bassofono.h"
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2021-12-31 04:22:22 +01:00
|
|
|
uint8_t menu_item, menu_page;
|
|
|
|
|
uint8_t menu_last_item[MENU_PAGE_EOM + 1];
|
2021-07-02 22:19:04 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
typedef void (*menu_set_function)(void);
|
|
|
|
|
typedef void (*menu_print_function)(uint8_t a);
|
|
|
|
|
|
|
|
|
|
struct menu_item {
|
2021-12-31 04:22:22 +01:00
|
|
|
uint8_t page;
|
2021-07-02 22:19:04 +02:00
|
|
|
char name[14];
|
|
|
|
|
uint8_t type;
|
|
|
|
|
uint8_t size;
|
|
|
|
|
uint8_t row;
|
|
|
|
|
uint8_t col;
|
|
|
|
|
uint32_t step;
|
|
|
|
|
uint32_t min;
|
|
|
|
|
uint32_t max;
|
|
|
|
|
uint8_t wrap;
|
2021-12-31 04:22:22 +01:00
|
|
|
char suffix[3];
|
2021-07-02 22:19:04 +02:00
|
|
|
uint32_t *varptr;
|
|
|
|
|
menu_set_function set_function_ptr;
|
|
|
|
|
menu_print_function print_function_ptr;
|
|
|
|
|
};
|
|
|
|
|
*/
|
|
|
|
|
|
2021-12-31 04:22:22 +01:00
|
|
|
// size deve comprendere lo spazio per il '>', eccetto che per i campi NED
|
|
|
|
|
// set_function_ptr viene applicata dopo che varptr e' stata modificata con
|
|
|
|
|
|
|
|
|
|
// name, type, size,row,col,step, min, max, wrap suffix *varptr, set_function_ptr print_function_ptr
|
2021-07-02 22:19:04 +02:00
|
|
|
struct menu_item items[] = {
|
2021-12-31 04:22:22 +01:00
|
|
|
{MENU_PAGE_DEFAULT, " Frequency", TYP_INT, 9, 1, 0, 100, 1000, 175000, WRAP, "", " Hz", &frequency, &set_frequency, &print_frequency},
|
|
|
|
|
// {MENU_PAGE_DEFAULT, " Rit ", TYP_INT, 4, 2, 0, 10, 0, 9999, SAT, "", "", &rit, &set_frequency, &print_frequency},
|
|
|
|
|
{MENU_PAGE_DEFAULT, " Volume ", TYP_INT, 5, 2, 0, 1, 0, 32, SAT, "", "|", &volume, &set_dummy, &print_bar},
|
|
|
|
|
{MENU_PAGE_DEFAULT, " Gain ", TYP_INT, 1, 2, 7, 1, 1, 6, SAT, "", "x", &gain, &set_gain, &print_integer},
|
|
|
|
|
{MENU_PAGE_DEFAULT, " Modulation", TYP_INT, 3, 2, 10, 1, 0, 3, WRAP, "", "", &modulation, &set_modulation,&print_modulation},
|
|
|
|
|
// {MENU_PAGE_DEFAULT, " Squelch ", TYP_INT, 2, 3, 10, 1, 0, 32, SAT, "", "", &squelch, &set_dummy, &print_integer},
|
|
|
|
|
|
|
|
|
|
{MENU_PAGE_AUDIO, " Filter CF ", TYP_INT, 4, 1, 0, 50, 50, 3500, SAT, "", " Hz", &audio_filter_freq, &set_filter, &print_integer},
|
|
|
|
|
{MENU_PAGE_AUDIO, " Filter BW ", TYP_INT, 4, 2, 0, 50, 50, 2500, SAT, "", " Hz", &audio_filter_bw, &set_filter, &print_integer},
|
|
|
|
|
{MENU_PAGE_AUDIO, " Filter Q ", TYP_INT, 2, 3, 0, 1, 1, 32, SAT, "", " Q", &audio_filter_beta, &set_filter, &print_integer},
|
|
|
|
|
|
|
|
|
|
{MENU_PAGE_ALL, " Signal ", TYP_NED, 13, 4, 0, 0, 0, 0, SAT, "S", "", &s_meter, &set_dummy, &print_bar},
|
|
|
|
|
{MENU_PAGE_ALL, " TX tab ", TYP_NED, 3, 5, 0, 0, 0, 0, SAT, "", "", "PTT", &set_dummy, &print_string},
|
|
|
|
|
{MENU_PAGE_ALL, " Tabs ", TYP_NED, 3, 5, 4, 0, 0, 0, SAT, "", "", "SET", &set_dummy, &print_string},
|
2022-01-01 02:10:06 +01:00
|
|
|
{MENU_PAGE_ALL, " Tabs ", TYP_NED, 2, 5, 9, 0, 0, 0, SAT, "", "", "BL", &set_dummy, &print_string},
|
2021-12-31 04:22:22 +01:00
|
|
|
{MENU_PAGE_ALL, " Tabs ", TYP_NED, 1, 5, 12, 0, 0, 0, SAT, "", "", "+", &set_dummy, &print_string},
|
2021-07-02 22:19:04 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-31 04:22:22 +01:00
|
|
|
/*
|
2021-07-02 22:19:04 +02:00
|
|
|
struct menu_item tabs[] = {
|
2021-12-31 04:22:22 +01:00
|
|
|
{MENU_PAGE_DEFAULT, "SCN", TYP_INT, 3, 0, 0, 1, 0, 3, WRAP, "Hz", &scan, &set_dummy, &print_integer},
|
2021-07-02 22:19:04 +02:00
|
|
|
};
|
2021-12-31 04:22:22 +01:00
|
|
|
*/
|
2021-07-02 22:19:04 +02:00
|
|
|
|
|
|
|
|
uint8_t menu_item_count = sizeof(items)/sizeof(items[0]);
|
2021-12-31 04:22:22 +01:00
|
|
|
// uint8_t tabs_count = sizeof(tabs)/sizeof(tabs[0]);
|
2021-07-02 22:19:04 +02:00
|
|
|
|
|
|
|
|
char modulation_list[][4] = {
|
|
|
|
|
[MOD_DC] = "DC",
|
|
|
|
|
[MOD_LSB] = "LSB",
|
|
|
|
|
[MOD_USB] = "USB",
|
|
|
|
|
[MOD_AM] = "AM"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
uint8_t modulation_list_count = sizeof(modulation_list)/sizeof(modulation_list[0]);
|
|
|
|
|
|
2021-12-31 04:22:22 +01:00
|
|
|
char status_list[][3] = {
|
|
|
|
|
[STATUS_RX] = "Rx",
|
|
|
|
|
[STATUS_TX] = "Tx",
|
|
|
|
|
[STATUS_SQ] = "Sq",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
uint8_t status_list_count = sizeof(status_list)/sizeof(status_list[0]);
|
|
|
|
|
|
|
|
|
|
// == ################################ ==
|
|
|
|
|
|
2021-07-02 22:19:04 +02:00
|
|
|
void decode_cmd(char cmd){
|
|
|
|
|
switch(cmd){
|
|
|
|
|
case ENRH:
|
|
|
|
|
encoder_increment();
|
2021-07-03 04:08:08 +02:00
|
|
|
click();
|
2021-07-02 22:19:04 +02:00
|
|
|
break;
|
|
|
|
|
case ENLH:
|
|
|
|
|
encoder_decrement();
|
2021-07-03 04:08:08 +02:00
|
|
|
click();
|
2021-07-02 22:19:04 +02:00
|
|
|
break;
|
|
|
|
|
case JSRP:
|
|
|
|
|
joystick_dx();
|
2021-07-03 04:08:08 +02:00
|
|
|
click();
|
2021-07-02 22:19:04 +02:00
|
|
|
break;
|
|
|
|
|
case JSLP:
|
|
|
|
|
joystick_sx();
|
2021-07-03 04:08:08 +02:00
|
|
|
click();
|
2021-07-02 22:19:04 +02:00
|
|
|
break;
|
|
|
|
|
case JSUP:
|
|
|
|
|
joystick_up();
|
2021-07-03 04:08:08 +02:00
|
|
|
click();
|
2021-07-02 22:19:04 +02:00
|
|
|
break;
|
|
|
|
|
case JSDP:
|
|
|
|
|
joystick_down();
|
2021-07-03 04:08:08 +02:00
|
|
|
click();
|
2021-07-02 22:19:04 +02:00
|
|
|
break;
|
|
|
|
|
case JSBP:
|
|
|
|
|
joystick_button();
|
2021-07-03 04:08:08 +02:00
|
|
|
click();
|
2021-07-02 22:19:04 +02:00
|
|
|
break;
|
|
|
|
|
case BT1P:
|
|
|
|
|
tab_up(0);
|
|
|
|
|
break;
|
|
|
|
|
case BT2P:
|
|
|
|
|
tab_up(1);
|
|
|
|
|
break;
|
|
|
|
|
case BT3P:
|
|
|
|
|
tab_up(2);
|
|
|
|
|
break;
|
|
|
|
|
case BT4P:
|
|
|
|
|
tab_up(3);
|
|
|
|
|
break;
|
|
|
|
|
case BT1R:
|
|
|
|
|
tab_down(0);
|
|
|
|
|
break;
|
|
|
|
|
case BT2R:
|
|
|
|
|
tab_down(1);
|
|
|
|
|
break;
|
|
|
|
|
case BT3R:
|
|
|
|
|
tab_down(2);
|
|
|
|
|
break;
|
|
|
|
|
case BT4R:
|
|
|
|
|
tab_down(3);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void encoder_increment(void){
|
2021-12-31 04:22:22 +01:00
|
|
|
if(items[menu_item].type == TYP_INT) integer_editor_up(menu_item);
|
|
|
|
|
items[menu_item].set_function_ptr();
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void encoder_decrement(void){
|
2021-12-31 04:22:22 +01:00
|
|
|
if(items[menu_item].type == TYP_INT) integer_editor_down(menu_item);
|
|
|
|
|
items[menu_item].set_function_ptr();
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void joystick_dx(void){
|
2021-12-31 04:22:22 +01:00
|
|
|
step_down(menu_item);
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void joystick_sx(void){
|
2021-12-31 04:22:22 +01:00
|
|
|
step_up(menu_item);
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void joystick_down(void){
|
2021-12-31 04:22:22 +01:00
|
|
|
menu_item_up();
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void joystick_up(void){
|
2021-12-31 04:22:22 +01:00
|
|
|
menu_item_down();
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void joystick_button(void){
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 04:22:22 +01:00
|
|
|
void menu_item_up(void){
|
|
|
|
|
set_changed(menu_item); // pulisci vecchio
|
|
|
|
|
menu_item++;
|
|
|
|
|
// if((items[menu_item].type == TYP_NED) || (items[menu_item].page != menu_page)) menu_item++;
|
|
|
|
|
while((items[menu_item].type == TYP_NED) || (items[menu_item].page != menu_page)){
|
|
|
|
|
menu_item++;
|
|
|
|
|
if(menu_item >= menu_item_count) menu_item = 0;
|
|
|
|
|
}
|
|
|
|
|
set_changed(menu_item); // cursore nel nuovo
|
2021-07-02 22:19:04 +02:00
|
|
|
// nome
|
2021-12-31 04:22:22 +01:00
|
|
|
display_update_item();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void menu_item_down(void){
|
|
|
|
|
set_changed(menu_item); // pulisci vecchio
|
|
|
|
|
menu_item--;
|
|
|
|
|
if(menu_item >= menu_item_count) menu_item = menu_item_count - 1;
|
|
|
|
|
// if(menu_item >= menu_item_count) menu_item = menu_item_count - 1;
|
|
|
|
|
// if((items[menu_item].type == TYP_NED) || (items[menu_item].page != menu_page)) menu_item--;
|
|
|
|
|
// if(menu_item >= menu_item_count) menu_item = menu_item_count - 1;
|
|
|
|
|
while((items[menu_item].type == TYP_NED) || (items[menu_item].page != menu_page)){
|
|
|
|
|
menu_item--;
|
|
|
|
|
if(menu_item >= menu_item_count) menu_item = menu_item_count - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_changed(menu_item); // nuovo
|
|
|
|
|
display_update_item();
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void step_up(uint8_t mode){
|
|
|
|
|
if((items[mode].step * 10) < items[mode].max) items[mode].step *= 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void step_down(uint8_t mode){
|
|
|
|
|
if(items[mode].step >= 10) items[mode].step /= 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void interface_set_default(void){
|
2021-12-31 04:22:22 +01:00
|
|
|
menu_item = 0;
|
|
|
|
|
menu_page = MENU_PAGE_DEFAULT;
|
|
|
|
|
menu_last_item[MENU_PAGE_DEFAULT] = 0;
|
|
|
|
|
menu_last_item[MENU_PAGE_AUDIO] = 4;
|
|
|
|
|
strcpy(tabstring, "TX SET MEM NO");
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void display_set_position(uint8_t row, uint8_t col){
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[%d,%dz", col, row);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 04:22:22 +01:00
|
|
|
/*
|
2021-07-02 22:19:04 +02:00
|
|
|
void display_print_string(uint8_t row, uint8_t col, char * string){
|
|
|
|
|
display_set_position(row,col);
|
|
|
|
|
enqueue_tx(string, strlen(string));
|
|
|
|
|
}
|
2021-12-31 04:22:22 +01:00
|
|
|
*/
|
2021-07-02 22:19:04 +02:00
|
|
|
|
2021-12-31 04:22:22 +01:00
|
|
|
void display_update_item(void){
|
2021-07-02 22:19:04 +02:00
|
|
|
display_set_position(MENU_NAME_ROW,MENU_NAME_COL);
|
2021-12-31 04:22:22 +01:00
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"%d %-12s", menu_item, items[menu_item].name);
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void display_update_state(void){
|
|
|
|
|
uint8_t var;
|
|
|
|
|
for(uint8_t item_idx = 0; item_idx < (menu_item_count); item_idx++){
|
|
|
|
|
if(get_changed(item_idx)){
|
2021-12-31 04:22:22 +01:00
|
|
|
if(((items[item_idx].page == menu_page) || (items[item_idx].page == MENU_PAGE_ALL) )&& (items[item_idx].type != TYP_HID)){
|
|
|
|
|
// posizionati
|
|
|
|
|
display_set_position(items[item_idx].row,items[item_idx].col);
|
|
|
|
|
// setta o meno il >
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx, items[item_idx].prefix);
|
|
|
|
|
if(items[item_idx].type != TYP_NED){
|
|
|
|
|
if(item_idx == menu_item) uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx, ">");
|
|
|
|
|
else {
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx, " ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// stampa valore
|
|
|
|
|
// if(items[item_idx].type != TYP_HID) items[item_idx].print_function_ptr(item_idx);
|
|
|
|
|
items[item_idx].print_function_ptr(item_idx);
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx, items[item_idx].suffix);
|
|
|
|
|
|
|
|
|
|
// if(items[item_idx].type == TYP_INT) uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"%0*ld", items[item_idx].size, * items[item_idx].varptr);
|
|
|
|
|
// if(items[item_idx].type == TYP_LIST) uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"%*s", items[item_idx].size, &items[item_idx].mapptr[* items[item_idx].varptr]);
|
|
|
|
|
}
|
|
|
|
|
// resetta
|
2021-07-02 22:19:04 +02:00
|
|
|
reset_changed(item_idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void integer_editor_up(uint8_t mode){
|
|
|
|
|
* items[mode].varptr += items[mode].step;
|
|
|
|
|
if((* items[mode].varptr < items[mode].min) || (* items[mode].varptr > items[mode].max)){
|
|
|
|
|
if(items[mode].wrap){
|
|
|
|
|
* items[mode].varptr = items[mode].min;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
* items[mode].varptr = items[mode].max;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
set_changed(mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void integer_editor_down(uint8_t mode){
|
|
|
|
|
* items[mode].varptr -= items[mode].step;
|
|
|
|
|
if((* items[mode].varptr < items[mode].min) || (* items[mode].varptr > items[mode].max)){
|
|
|
|
|
if(items[mode].wrap){
|
|
|
|
|
* items[mode].varptr = items[mode].max;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
* items[mode].varptr = items[mode].min;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
set_changed(mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void list_editor_down(uint8_t mode){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void tabs_update(void){
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\a");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void tab_up(uint8_t tab){
|
|
|
|
|
switch(tab){
|
|
|
|
|
case 0:
|
|
|
|
|
stop_receive();
|
|
|
|
|
start_transmit();
|
|
|
|
|
break;
|
2021-12-31 04:22:22 +01:00
|
|
|
case 1:
|
|
|
|
|
menu_last_item[menu_page] = menu_item;
|
|
|
|
|
menu_page++;
|
|
|
|
|
if(menu_page > MENU_PAGE_EOM) menu_page = MENU_PAGE_SOM;
|
|
|
|
|
menu_item = menu_last_item[menu_page];
|
|
|
|
|
|
|
|
|
|
state_changed = 0xFFFF;
|
|
|
|
|
clear_display();
|
|
|
|
|
display_update_item();
|
|
|
|
|
display_update_state();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2022-01-01 02:10:06 +01:00
|
|
|
// encoder_increment();
|
|
|
|
|
// click();
|
|
|
|
|
display_backlight_on();
|
2021-12-31 04:22:22 +01:00
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
encoder_decrement();
|
|
|
|
|
click();
|
|
|
|
|
break;
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void tab_down(uint8_t tab){
|
|
|
|
|
switch(tab){
|
|
|
|
|
case 0:
|
|
|
|
|
stop_transmit();
|
|
|
|
|
start_receive();
|
|
|
|
|
break;
|
2022-01-01 02:10:06 +01:00
|
|
|
case 2:
|
|
|
|
|
display_backlight_off();
|
|
|
|
|
break;
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void display_init(void){
|
2021-12-31 04:22:22 +01:00
|
|
|
// https://git.lattuga.net/asdrea/tosta
|
|
|
|
|
// caratteri print_bar
|
2021-07-02 22:19:04 +02:00
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[128,255,0,0,0,0,0c");
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[129,255,255,0,0,0,0c");
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[130,255,255,255,0,0,0c");
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[131,255,255,255,255,0,0c");
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[132,255,255,255,255,255,0c");
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[133,255,255,255,255,255,255c");
|
2021-12-31 04:22:22 +01:00
|
|
|
|
2021-07-02 22:19:04 +02:00
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[%ds",DISPLAY_STANDBY_TIMER);
|
2021-12-31 04:22:22 +01:00
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[150,100q");
|
2022-01-01 02:10:06 +01:00
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[%db",0);
|
2021-12-31 04:22:22 +01:00
|
|
|
// uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\a");
|
|
|
|
|
clear_display();
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// menu prints
|
2021-12-31 04:22:22 +01:00
|
|
|
void print_dummy(uint8_t item_idx){
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-02 22:19:04 +02:00
|
|
|
void print_integer(uint8_t item_idx){
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"%*ld", items[item_idx].size, * items[item_idx].varptr);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 04:22:22 +01:00
|
|
|
void print_string(uint8_t item_idx){
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"%*s", items[item_idx].size, items[item_idx].varptr);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-02 22:19:04 +02:00
|
|
|
void print_modulation(uint8_t item_idx){
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"%*s", items[item_idx].size, modulation_list[*items[item_idx].varptr]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void print_bar(uint8_t item_idx){
|
2021-12-31 04:22:22 +01:00
|
|
|
// il range massimo e' items[item_idx].size * 6
|
|
|
|
|
uint8_t i, cols;
|
2021-07-02 22:19:04 +02:00
|
|
|
cols = *items[item_idx].varptr;
|
|
|
|
|
char buf[items[item_idx].size];
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < items[item_idx].size; i++){
|
|
|
|
|
if(cols >= 6){
|
|
|
|
|
buf[i] = 133;
|
|
|
|
|
} else if (cols > 0){
|
|
|
|
|
buf[i] = 128 + cols;
|
|
|
|
|
} else {
|
|
|
|
|
buf[i] = 32;
|
|
|
|
|
}
|
|
|
|
|
cols = sat_subu8b(cols, 6);
|
|
|
|
|
}
|
2021-12-31 04:22:22 +01:00
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx, buf);
|
2021-07-02 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void print_frequency(uint8_t item_idx){
|
|
|
|
|
char bufin[14];
|
|
|
|
|
char bufout[14];
|
2021-12-31 04:22:22 +01:00
|
|
|
uint8_t i, j, unformatted_size;
|
2021-07-02 22:19:04 +02:00
|
|
|
j = 0;
|
2021-12-31 04:22:22 +01:00
|
|
|
// unformatted_size = items[item_idx].size;
|
2021-07-02 22:19:04 +02:00
|
|
|
sprintf(bufin,"%8ld", * items[item_idx].varptr);
|
|
|
|
|
for(i=0; bufin[i] != '\0'; i++){
|
|
|
|
|
if((((strlen(bufin)-i)%3)==0) && (i != 0)) {
|
|
|
|
|
if(bufin[i-1] == ' '){
|
|
|
|
|
bufout[j] = ' ';
|
|
|
|
|
} else {
|
|
|
|
|
bufout[j] = '.';
|
|
|
|
|
}
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
bufout[j] = bufin[i];
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
bufout[j] = '\0';
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"%s", bufout);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 04:22:22 +01:00
|
|
|
// ###
|
|
|
|
|
|
2021-07-02 22:19:04 +02:00
|
|
|
void scan_do(uint8_t scan_state){
|
|
|
|
|
static uint8_t scan_timer;
|
|
|
|
|
frequency += items[0].step * scan_state;
|
|
|
|
|
set_frequency();
|
|
|
|
|
set_changed(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t sat_subu8b(uint8_t x, uint8_t y){
|
|
|
|
|
uint8_t res = x - y;
|
|
|
|
|
res &= -(res <= x);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2021-07-03 04:08:08 +02:00
|
|
|
|
|
|
|
|
void click(void){
|
2021-12-31 04:22:22 +01:00
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[600,5q");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void clear_display(void){
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\f");
|
2021-07-03 04:08:08 +02:00
|
|
|
}
|
2022-01-01 02:10:06 +01:00
|
|
|
|
|
|
|
|
void display_backlight_on(void){
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[%db",DISPLAY_BL_DIM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void display_backlight_off(void){
|
|
|
|
|
uart_tx_buf_in_idx += sprintf(uart_tx_buf+uart_tx_buf_in_idx,"\x1B[%db",0);
|
|
|
|
|
}
|