diff --git a/MW_OSD/Config.h b/MW_OSD/Config.h index c9e78d4a..55cbe806 100644 --- a/MW_OSD/Config.h +++ b/MW_OSD/Config.h @@ -1,5 +1,12 @@ /*-------------------------- initialisation options ----------------------------------------------------*/ -//#define EEPROM_CLEAR // Uncomment to force a wipe and reload of default settings at each OSD start. Same as EEPROM_CLEAR sketch. Recomment/upload once completed. +// Ignore this section unless you know you need to use it !! +// This section contains initialisation options that only require to be run once. +// Once the initialisation has completed, all sections should be commented and the sketch re-uploaded. + +//#define EEPROM_CLEAR // Uncomment to force a wipe and reload of default settings at each OSD start. Same as EEPROM_CLEAR sketch. +//#define LOADFONT_DEFAULT // Uncomment to force an upload of default font instead of using GUI +//#define LOADFONT_LARGE // Uncomment to force an upload of large font instead of using GUI + /*-------------------------- configurable parameters ----------------------------------------------------*/ diff --git a/MW_OSD/GlobalVariables.h b/MW_OSD/GlobalVariables.h index 52ae5085..d2f6a71d 100644 --- a/MW_OSD/GlobalVariables.h +++ b/MW_OSD/GlobalVariables.h @@ -702,6 +702,13 @@ const char message0[] PROGMEM = INTRO_VERSION; #else const char message0[] PROGMEM = MWVERS; #endif + +#if defined LOADFONT_DEFAULT || defined LOADFONT_LARGE +const char messageF0[] PROGMEM = "DO NOT POWER OFF"; +const char messageF1[] PROGMEM = "SCREEN WILL GO BLANK"; +const char messageF2[] PROGMEM = "UPDATE COMPLETE"; +#endif + //const char message1[] PROGMEM = "VIDEO SIGNAL NTSC"; //const char message2[] PROGMEM = "VIDEO SIGNAL PAL "; const char message5[] PROGMEM = "FW VERSION:"; diff --git a/MW_OSD/MW_OSD.ino b/MW_OSD/MW_OSD.ino index b5ccebc3..4e38779d 100644 --- a/MW_OSD/MW_OSD.ino +++ b/MW_OSD/MW_OSD.ino @@ -82,6 +82,11 @@ uint16_t UntouchedStack(void) #if defined NAZA #include "Naza.h" #endif +#if defined LOADFONT_LARGE + #include "fontL.h" +#elif defined LOADFONT_DEFAULT + #include "fontD.h" +#endif char screen[480]; // Main screen ram for MAX7456 char screenBuffer[20]; @@ -91,6 +96,15 @@ uint8_t sensorpinarray[]={VOLTAGEPIN,VIDVOLTAGEPIN,AMPERAGEPIN,TEMPPIN,RSSIPIN}; unsigned long previous_millis_low=0; unsigned long previous_millis_high =0; +#if defined LOADFONT_DEFAULT || defined LOADFONT_LARGE +uint8_t fontStatus=0; +//uint16_t MAX_screen_size; +boolean ledstatus=HIGH; +//uint8_t fontData[54]; +//uint8_t Settings[1]; +#endif + + //------------------------------------------------------------------------ void setup() @@ -143,7 +157,33 @@ void setup() } - +//------------------------------------------------------------------------ +#if defined LOADFONT_DEFAULT || defined LOADFONT_LARGE +void loop() +{ + switch(fontStatus) { + case 0: + MAX7456_WriteString_P(messageF0, 32); + MAX7456_DrawScreen(); + delay(3000); + displayFont(); + MAX7456_WriteString_P(messageF1, 32); + MAX7456_DrawScreen(); + fontStatus++; + delay(3000); + break; + case 1: + updateFont(); + MAX7456Setup(); + MAX7456_WriteString_P(messageF2, 32); + displayFont(); + MAX7456_DrawScreen(); + fontStatus++; + break; + } + digitalWrite(LEDPIN,LOW); +} +#else //------------------------------------------------------------------------ void loop() @@ -463,7 +503,7 @@ void loop() // setMspRequests(); serialMSPreceive(1); } // End of main loop - +#endif //main loop //------------------------------------------------------------------------ diff --git a/MW_OSD/Max7456.ino b/MW_OSD/Max7456.ino index b6945fdd..8f0855e5 100644 --- a/MW_OSD/Max7456.ino +++ b/MW_OSD/Max7456.ino @@ -371,4 +371,32 @@ void MAX7456Stalldetect(void){ digitalWrite(MAX7456SELECT,HIGH); if ((B00001000 & srdata) == 0) MAX7456Setup(); -} +} + +#if defined LOADFONT_DEFAULT || defined LOADFONT_LARGE +void displayFont() +{ + for(uint8_t x = 0; x < 255; x++) { + screen[90+x] = x; + } +} + +void updateFont() +{ + for(uint8_t x = 0; x < 255; x++){ + for(uint8_t i = 0; i < 54; i++){ + fontData[i] = (uint8_t)pgm_read_byte(fontdata+(64*x)+i); + } + write_NVM(x); + ledstatus=!ledstatus; + if (ledstatus==true){ + digitalWrite(LEDPIN,HIGH); + } + else{ + digitalWrite(LEDPIN,LOW); + } + delay(20); // Shouldn't be needed due to status reg wait. + } +} +#endif + diff --git a/OTHER/MWOSD_Font_Updater/fontD.h b/MW_OSD/fontD.h similarity index 100% rename from OTHER/MWOSD_Font_Updater/fontD.h rename to MW_OSD/fontD.h diff --git a/OTHER/MWOSD_Font_Updater/fontL.h b/MW_OSD/fontL.h similarity index 100% rename from OTHER/MWOSD_Font_Updater/fontL.h rename to MW_OSD/fontL.h diff --git a/OTHER/MWOSD_Font_Updater/MWOSD_Font_Updater.ino b/OTHER/MWOSD_Font_Updater/MWOSD_Font_Updater.ino deleted file mode 100644 index ffc8ed12..00000000 --- a/OTHER/MWOSD_Font_Updater/MWOSD_Font_Updater.ino +++ /dev/null @@ -1,557 +0,0 @@ -// Font updater utility for MINIM based OSD's -// This Utility will overwrite any existing sketch on the arduino -// It will not overwrite any EEPROM settings - - -// Select the font you wish to install -#define STANDARD -//#define LARGE - -// Once sketch uploaded: -// Power cycle the OSD. -// After approx 30-60 seconds the LED will stop flashing. -// The display will dvise update comple and display the font map. -// Re-install the OSD sketch. - -//-------------------------------------------------------------- -// -#define LEDPIN 7 -#define MAX7456SELECT 6 // ss -#define MAX7456RESET 10 // RESET -#define DECIMAL '.' -#define POS_MASK 0x01FF -#define PAL_MASK 0x0003 -#define PAL_SHFT 9 -#define DISPLAY_MASK 0xC000 -#define DISPLAY_ALWAYS 0xC000 -#define DISPLAY_NEVER 0x0000 -#define DISPLAY_COND 0x4000 -#define DISPLAY_MIN_OFF 0x8000 -#define POS(pos, pal_off, disp) (((pos)&POS_MASK)|((pal_off)< -#if defined LARGE - #include "fontL.h" -#else - #include "fontD.h" -#endif -char screen[480]; // Main screen ram for MAX7456 -char screenBuffer[20]; -uint8_t fontStatus=0; - - -//------------------------------------------------------------------------ -void setup() -{ - #define STARTUPDELAY 1000 - delay(STARTUPDELAY); - MAX7456Setup(); - pinMode(LEDPIN,OUTPUT); - digitalWrite(LEDPIN,HIGH); -// for(uint8_t x = 0; x < 480; x++) { -// screen[x] = 0X3F; -// } -} - - - -//------------------------------------------------------------------------ -void loop() -{ - switch(fontStatus) { - case 0: - MAX7456_WriteString_P(message0, 32); - MAX7456_DrawScreen(); - delay(3000); - displayFont(); - MAX7456_WriteString_P(message1, 32); - MAX7456_DrawScreen(); - fontStatus++; - delay(3000); - break; - case 1: - updateFont(); - MAX7456Setup(); - MAX7456_WriteString_P(message2, 32); - displayFont(); - MAX7456_DrawScreen(); - fontStatus++; - break; - } - digitalWrite(LEDPIN,LOW); -} - - -void displayFont() -{ - for(uint8_t x = 0; x < 255; x++) { - screen[90+x] = x; - } -} - - -void updateFont() -{ - for(uint8_t x = 0; x < 255; x++){ - for(uint8_t i = 0; i < 54; i++){ - fontData[i] = (uint8_t)pgm_read_byte(fontdata+(64*x)+i); - } - write_NVM(x); - ledstatus=!ledstatus; - if (ledstatus==true){ - digitalWrite(LEDPIN,HIGH); - } - else{ - digitalWrite(LEDPIN,LOW); - } - delay(20); // Shouldn't be needed due to status reg wait. - } -} - - -////////////////////////////////////////////////////////////// -uint8_t spi_transfer(uint8_t data) -{ - SPDR = data; // Start the transmission - while (!(SPSR & (1<vsynctimer){ - vsync_wait=0; - } - else{ -// serialMSPreceive(0); // Might as well do something whilst waiting :) - } - } - SPDR = screen[xx]; - screen[xx] = ' '; - while (!(SPSR & (1<>8); - MAX7456_Send(MAX7456ADD_DMAL, xx); - MAX7456_Send(MAX7456ADD_DMDI, screen[xx]); - screen[xx] = ' '; - #endif - } - #ifdef USE_VSYNC - spi_transfer(DMDI_reg); - spi_transfer(END_string); - spi_transfer(DMM_reg); - spi_transfer(B00000000); - #endif - digitalWrite(MAX7456SELECT,HIGH); -} - - -void MAX7456_Send(uint8_t add, uint8_t data) -{ - spi_transfer(add); - spi_transfer(data); -} - - -//MAX7456 commands - -#define WRITE_TO_MAX7456 -#define NVM_ram_size 54 - -#define CLEAR_display 0x04 -#define CLEAR_display_vert 0x06 -#define END_string 0xff -#define WRITE_nvr 0xa0 -// with NTSC -#define ENABLE_display 0x08 -#define ENABLE_display_vert 0x0c -#define MAX7456_reset 0x02 -#define DISABLE_display 0x00 -#define STATUS_reg_nvr_busy 0x20 - -void write_NVM(uint8_t char_address) -{ -#ifdef WRITE_TO_MAX7456 - // disable display - digitalWrite(MAX7456SELECT,LOW); - spi_transfer(VM0_reg); - //spi_transfer(DISABLE_display); - - - - //digitalWrite(MAX7456SELECT,LOW); - //spi_transfer(VM0_reg); - spi_transfer(Settings[S_VIDEOSIGNALTYPE]?0x40:0); - - spi_transfer(MAX7456ADD_CMAH); // set start address high - spi_transfer(char_address); - - for(uint8_t x = 0; x < NVM_ram_size; x++) // write out 54 bytes of character to shadow ram - { - spi_transfer(MAX7456ADD_CMAL); // set start address low - spi_transfer(x); - spi_transfer(MAX7456ADD_CMDI); - spi_transfer(fontData[x]); - } - - // transfer 54 bytes from shadow ram to NVM - spi_transfer(MAX7456ADD_CMM); - spi_transfer(WRITE_nvr); - - // wait until bit 5 in the status register returns to 0 (12ms) - while ((spi_transfer(MAX7456ADD_STAT) & STATUS_reg_nvr_busy) != 0x00); - - spi_transfer(VM0_reg); // turn on screen next vertical - //spi_transfer(ENABLE_display_vert); - spi_transfer(Settings[S_VIDEOSIGNALTYPE]?0x4c:0x0c); - digitalWrite(MAX7456SELECT,HIGH); -#else - delay(12); -#endif -} - - -char *ItoaPadded(int val, char *str, uint8_t bytes, uint8_t decimalpos) { -// Val to convert -// Return String -// Length -// Decimal position - uint8_t neg = 0; - if(val < 0) { - neg = 1; - val = -val; - } - - str[bytes] = 0; - for(;;) { - if(bytes == decimalpos) { - str[--bytes] = DECIMAL; - decimalpos = 0; - } - str[--bytes] = '0' + (val % 10); - val = val / 10; - if(bytes == 0 || (decimalpos == 0 && val == 0)) - break; - } - - if(neg && bytes > 0) - str[--bytes] = '-'; - - while(bytes != 0) - str[--bytes] = ' '; - return str; -} - -char *FormatGPSCoord(int32_t val, char *str, uint8_t p, char pos, char neg) { - if(val < 0) { - pos = neg; - val = -val; - } - - uint8_t bytes = p+6; - val = val / 100; - - str[bytes] = 0; - str[--bytes] = pos; - for(;;) { - if(bytes == p) { - str[--bytes] = DECIMAL; - continue; - } - str[--bytes] = '0' + (val % 10); - val = val / 10; - if(bytes == 0 || (bytes < 3 && val == 0)) - break; } - - while(bytes != 0) - str[--bytes] = ' '; - - return str; -} - -// Take time in Seconds and format it as 'MM:SS' -// Alternately Take time in Minutes and format it as 'HH:MM' -// If hhmmss is 1, display as HH:MM:SS -char *formatTime(uint32_t val, char *str, uint8_t hhmmss) { - int8_t bytes = 5; - if(hhmmss) - bytes = 8; - str[bytes] = 0; - do { - str[--bytes] = '0' + (val % 10); - val = val / 10; - str[--bytes] = '0' + (val % 6); - val = val / 6; - str[--bytes] = ':'; - } while(hhmmss-- != 0); - do { - str[--bytes] = '0' + (val % 10); - val = val / 10; - } while(val != 0 && bytes != 0); - - while(bytes != 0) - str[--bytes] = ' '; - - return str; -} - -uint8_t FindNull(void) -{ - uint8_t xx; - for(xx=0;screenBuffer[xx]!=0;xx++) - ; - return xx; -} - - - - diff --git a/OTHER/MWOSD_Font_Updater/MWOSD_Font_Updater.xlsm b/OTHER/MWOSD_Font_Updater/MWOSD_Font_Updater.xlsm deleted file mode 100644 index 6c49e00b..00000000 Binary files a/OTHER/MWOSD_Font_Updater/MWOSD_Font_Updater.xlsm and /dev/null differ