Move formatFreq to nano_gui so that both ubitx_ui and setup can use the single function
This commit is contained in:
parent
d62ff59c90
commit
afeb056667
27
nano_gui.cpp
27
nano_gui.cpp
@ -8,6 +8,33 @@
|
||||
|
||||
struct Point ts_point;
|
||||
|
||||
/*
|
||||
* This formats the frequency given in f
|
||||
*/
|
||||
void formatFreq(uint32_t freq, char* buff, uint16_t buff_size) {
|
||||
memset(buff, 0, buff_size);
|
||||
|
||||
ultoa(freq, buff, DEC);
|
||||
uint8_t num_digits = strlen(buff);
|
||||
const uint8_t num_spacers = (num_digits-1) / 3;
|
||||
const uint8_t num_leading_digits_raw = num_digits % 3;
|
||||
const uint8_t num_leading_digits = (0 == num_leading_digits_raw) ? 3 : num_leading_digits_raw;
|
||||
|
||||
if(0 == num_spacers){
|
||||
return;
|
||||
}
|
||||
|
||||
buff += num_leading_digits;
|
||||
num_digits -= num_leading_digits;
|
||||
for(int i = num_digits-1; i >= 0; --i){
|
||||
buff[i + (i/3 + 1)] = buff[i];
|
||||
}
|
||||
for(unsigned int i = 0; i < num_spacers; ++i){
|
||||
memcpy_P(buff,F("."),1);
|
||||
buff += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void readTouchCalibration(){
|
||||
LoadSettingsFromEeprom();
|
||||
/* for debugging
|
||||
|
@ -18,6 +18,8 @@ void displayChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t
|
||||
void displayRawText(char *text, int x1, int y1, int color, int background);
|
||||
void displayText(char *text, int x1, int y1, int w, int h, int color, int background, int border);
|
||||
|
||||
void formatFreq(uint32_t freq, char* buff, uint16_t buff_size);
|
||||
|
||||
/* touch functions */
|
||||
boolean readTouch();
|
||||
|
||||
|
31
setup.cpp
31
setup.cpp
@ -73,34 +73,9 @@ void displayDialog(const __FlashStringHelper* title, const __FlashStringHelper*
|
||||
displayText(c, LAYOUT_INSTRUCTION_TEXT_X, LAYOUT_INSTRUCTION_TEXT_Y, LAYOUT_INSTRUCTION_TEXT_WIDTH, LAYOUT_INSTRUCTION_TEXT_HEIGHT, COLOR_TEXT, COLOR_BACKGROUND, COLOR_BACKGROUND);
|
||||
}
|
||||
|
||||
void printCarrierFreq(unsigned long freq){
|
||||
|
||||
memset(c, 0, sizeof(c));
|
||||
memset(b, 0, sizeof(b));
|
||||
|
||||
ultoa(freq, b, DEC);
|
||||
|
||||
unsigned int characters_remaining = strlen(b);
|
||||
char* destination = c;
|
||||
char* source = b;
|
||||
while(characters_remaining > 0){
|
||||
if(characters_remaining > 3){
|
||||
unsigned int characters_to_read = characters_remaining % 3;
|
||||
if(0 == characters_to_read){
|
||||
characters_to_read = 3;
|
||||
}
|
||||
memcpy(destination,source,characters_to_read);
|
||||
source += characters_to_read;
|
||||
destination += characters_to_read;
|
||||
characters_remaining -= characters_to_read;
|
||||
memcpy_P(destination,(const char*)F("."),1);
|
||||
destination += 1;
|
||||
}
|
||||
else{
|
||||
memcpy(destination,source,characters_remaining);
|
||||
characters_remaining -= characters_remaining;
|
||||
}
|
||||
}
|
||||
void printCarrierFreq(unsigned long freq)
|
||||
{
|
||||
formatFreq(freq,c,sizeof(c));
|
||||
displayText(c, LAYOUT_SETTING_VALUE_X, LAYOUT_SETTING_VALUE_Y, LAYOUT_SETTING_VALUE_WIDTH, LAYOUT_SETTING_VALUE_HEIGHT, COLOR_TEXT, COLOR_TITLE_BACKGROUND, COLOR_BACKGROUND);
|
||||
}
|
||||
|
||||
|
28
ubitx_ui.cpp
28
ubitx_ui.cpp
@ -148,34 +148,6 @@ boolean getButton(btn_set_e index, Button* button){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This formats the frequency given in f
|
||||
*/
|
||||
void formatFreq(uint32_t freq, char* buff, uint16_t buff_size) {
|
||||
memset(buff, 0, buff_size);
|
||||
|
||||
ultoa(freq, buff, DEC);
|
||||
uint8_t num_digits = strlen(buff);
|
||||
const uint8_t num_spacers = (num_digits-1) / 3;
|
||||
const uint8_t num_leading_digits_raw = num_digits % 3;
|
||||
const uint8_t num_leading_digits = (0 == num_leading_digits_raw) ? 3 : num_leading_digits_raw;
|
||||
|
||||
if(0 == num_spacers){
|
||||
return;
|
||||
}
|
||||
|
||||
buff += num_leading_digits;
|
||||
num_digits -= num_leading_digits;
|
||||
for(int i = num_digits-1; i >= 0; --i){
|
||||
buff[i + (i/3 + 1)] = buff[i];
|
||||
}
|
||||
for(unsigned int i = 0; i < num_spacers; ++i){
|
||||
memcpy_P(buff,F("."),1);
|
||||
buff += 4;
|
||||
}
|
||||
}
|
||||
|
||||
inline void drawCommandbar(char* text){
|
||||
displayText(text, LAYOUT_MODE_TEXT_X, LAYOUT_MODE_TEXT_Y, LAYOUT_MODE_TEXT_WIDTH, LAYOUT_MODE_TEXT_HEIGHT, COLOR_TEXT, COLOR_BACKGROUND, COLOR_BACKGROUND);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user