Skip to content

Commit

Permalink
Fontload option added to config.h
Browse files Browse the repository at this point in the history
Added option to upload fonts using a simple define in config.h
Supports basic fonts only for ease of maintenance
  • Loading branch information
ShikOfTheRa committed Aug 10, 2015
1 parent 4988080 commit 3a16608
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 561 deletions.
9 changes: 8 additions & 1 deletion MW_OSD/Config.h
Original file line number Diff line number Diff line change
@@ -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 ----------------------------------------------------*/
Expand Down
7 changes: 7 additions & 0 deletions MW_OSD/GlobalVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:";
Expand Down
44 changes: 42 additions & 2 deletions MW_OSD/MW_OSD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -463,7 +503,7 @@ void loop()
// setMspRequests();
serialMSPreceive(1);
} // End of main loop

#endif //main loop


//------------------------------------------------------------------------
Expand Down
30 changes: 29 additions & 1 deletion MW_OSD/Max7456.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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

File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 3a16608

Please sign in to comment.