mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Massively better font
Moved to a newer font. First stage of improving screen
This commit is contained in:
@@ -14,6 +14,7 @@ uint16_t readDCVoltage(uint16_t divFactor) {
|
||||
uint16_t reading = 0;
|
||||
for (u8 i = 0; i < 10; i++) {
|
||||
reading += ADC_GetConversionValue(ADC2);
|
||||
delayMs(5);
|
||||
}
|
||||
reading /= divFactor; //take the average and convert to X10 voltage
|
||||
return reading; //return the read voltage
|
||||
|
||||
@@ -154,7 +154,7 @@ void Adc_Init(void) {
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 1,
|
||||
ADC_SampleTime_239Cycles5); //28 or 55
|
||||
ADC_RegularChannelConfig(ADC2, ADC_Channel_9, 1,
|
||||
ADC_SampleTime_55Cycles5); //28 or 55
|
||||
ADC_SampleTime_239Cycles5); //28 or 55
|
||||
|
||||
/* Enable ADC1 DMA */
|
||||
ADC_DMACmd(ADC1, ENABLE);
|
||||
|
||||
@@ -28,8 +28,7 @@ int main(void) {
|
||||
OLED_SetOrientation(!getOrientation());
|
||||
RotationChangedFlag = 0;
|
||||
}
|
||||
|
||||
if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == Bit_RESET) {
|
||||
else if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == Bit_RESET) {
|
||||
OLED_SetOrientation(!getOrientation());
|
||||
RotationChangedFlag = 0;
|
||||
//^ This is a workaround for the IRQ being set off before we have the handler setup and enabled.
|
||||
@@ -64,6 +63,16 @@ void setup() {
|
||||
OLED_DrawString("VER 1.16", 8); //Version Number
|
||||
delayMs(400); //Pause to show version number
|
||||
showBootLogoIfavailable();
|
||||
//RESETs settings
|
||||
if (GPIO_ReadInputDataBit(GPIOA, KEY_B) == Bit_RESET) {
|
||||
OLED_DrawString("Reset ?", 8);
|
||||
delayMs(1000);
|
||||
if (GPIO_ReadInputDataBit(GPIOA, KEY_B) == Bit_RESET) {
|
||||
OLED_DrawString(" OK ", 8);
|
||||
delayMs(1000);
|
||||
resetSettings();
|
||||
}
|
||||
}
|
||||
Start_Watchdog(5000); //start the system watch dog as 5 second timeout
|
||||
|
||||
}
|
||||
|
||||
@@ -719,13 +719,14 @@ void DrawUI() {
|
||||
uint16_t voltage = readDCVoltage(systemSettings.voltageDiv); //get X10 voltage
|
||||
|
||||
if (StatusFlags == 0 || ((millis() % 1000) > 500)) {
|
||||
|
||||
OLED_DrawString("IN", 2);
|
||||
OLED_DrawChar((voltage / 100) % 10, 2);
|
||||
OLED_DrawChar(48+((voltage / 100) % 10), 2);
|
||||
voltage -= (voltage / 100) * 100;
|
||||
OLED_DrawChar((voltage / 10) % 10, 3);
|
||||
OLED_DrawChar(48+((voltage / 10) % 10), 3);
|
||||
voltage -= (voltage / 10) * 10;
|
||||
OLED_DrawChar('.', 4);
|
||||
OLED_DrawChar(voltage % 10, 5);
|
||||
OLED_DrawChar(48+(voltage % 10), 5);
|
||||
OLED_DrawChar('V', 6);
|
||||
OLED_DrawChar(' ', 7);
|
||||
} else {
|
||||
|
||||
@@ -186,27 +186,14 @@ void OLED_DrawString(const char* string, const uint8_t length) {
|
||||
void OLED_DrawChar(char c, uint8_t x) {
|
||||
if (x > 7)
|
||||
return; //clipping
|
||||
if (c > 127)
|
||||
return; //Not in this font
|
||||
x *= FONT_WIDTH; //convert to a x coordinate
|
||||
|
||||
u8* ptr = (u8*) FONT;
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
ptr += (c - 'a' + 10) * (FONT_WIDTH * 2); //alpha is ofset 10 chars into the array
|
||||
} else if (c >= 'A' && c <= 'Z') {
|
||||
ptr += (c - 'A' + 10) * (FONT_WIDTH * 2); //alpha is ofset 10 chars into the array
|
||||
} else if (c >= '0' && c <= '9')
|
||||
ptr += (c - '0') * (FONT_WIDTH * 2);
|
||||
else if (c < 10)
|
||||
ptr += (c) * (FONT_WIDTH * 2);
|
||||
else if (c == ' ') {
|
||||
//blank on space bar
|
||||
ptr += (36) * (FONT_WIDTH * 2);
|
||||
} else if (c == '<') {
|
||||
ptr += (37) * (FONT_WIDTH * 2);
|
||||
} else if (c == '>') {
|
||||
ptr += (38) * (FONT_WIDTH * 2);
|
||||
} else if (c == '.') {
|
||||
ptr += (39) * (FONT_WIDTH * 2);
|
||||
}
|
||||
u16 offset = c - ' ';
|
||||
offset *= (2 * FONT_WIDTH);
|
||||
ptr += offset;
|
||||
|
||||
Oled_DrawArea(x, 0, FONT_WIDTH, 16, (u8*) ptr);
|
||||
}
|
||||
@@ -237,27 +224,27 @@ void OLED_BlankSlot(uint8_t xStart, uint8_t width) {
|
||||
*/
|
||||
void OLED_DrawTwoNumber(uint8_t in, uint8_t x) {
|
||||
|
||||
OLED_DrawChar((in / 10) % 10, x);
|
||||
OLED_DrawChar(in % 10, x + 1);
|
||||
OLED_DrawChar(48 + (in / 10) % 10, x);
|
||||
OLED_DrawChar(48 + in % 10, x + 1);
|
||||
}
|
||||
/*
|
||||
* Draw a 3 digit number to the display at letter slot x
|
||||
*/
|
||||
void OLED_DrawThreeNumber(uint16_t in, uint8_t x) {
|
||||
|
||||
OLED_DrawChar((in / 100) % 10, x);
|
||||
OLED_DrawChar((in / 10) % 10, x + 1);
|
||||
OLED_DrawChar(in % 10, x + 2);
|
||||
OLED_DrawChar(48 + (in / 100) % 10, x);
|
||||
OLED_DrawChar(48 + (in / 10) % 10, x + 1);
|
||||
OLED_DrawChar(48 + in % 10, x + 2);
|
||||
}
|
||||
/*
|
||||
* Draw a 4 digit number to the display at letter slot x
|
||||
*/
|
||||
void OLED_DrawFourNumber(uint16_t in, uint8_t x) {
|
||||
|
||||
OLED_DrawChar((in / 1000) % 10, x);
|
||||
OLED_DrawChar((in / 100) % 10, x + 1);
|
||||
OLED_DrawChar((in / 10) % 10, x + 2);
|
||||
OLED_DrawChar(in % 10, x + 3);
|
||||
OLED_DrawChar(48 + (in / 1000) % 10, x);
|
||||
OLED_DrawChar(48 + (in / 100) % 10, x + 1);
|
||||
OLED_DrawChar(48 + (in / 10) % 10, x + 2);
|
||||
OLED_DrawChar(48 + (in % 10), x + 3);
|
||||
}
|
||||
|
||||
void OLED_DrawIDLELogo() {
|
||||
|
||||
@@ -38,7 +38,6 @@ void restoreSettings() {
|
||||
if (systemSettings.version != SETTINGSVERSION) {
|
||||
//probably not setup
|
||||
resetSettings();
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -74,7 +73,8 @@ void resetSettings() {
|
||||
systemSettings.boostModeEnabled = 0;//Default to safe, with no boost mode
|
||||
systemSettings.BoostTemp = 4000; //default to 400C
|
||||
systemSettings.powerDisplay = 0; //default to power display being off
|
||||
systemSettings.autoStart=0; //Auto start off for safety
|
||||
systemSettings.autoStart = 0; //Auto start off for safety
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
void showBootLogoIfavailable() {
|
||||
|
||||
Reference in New Issue
Block a user