mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
@@ -55,7 +55,7 @@ void GPIO_Config(void) {
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE); // GPIOB & AFIO
|
||||
|
||||
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE);
|
||||
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
|
||||
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);//disables jtag and maps pins for SWD
|
||||
|
||||
//------ PA7 TMP36 Analog input ----------------------------------------//
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
|
||||
@@ -63,7 +63,7 @@ void GPIO_Config(void) {
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
//------ OLED_RST_PIN(PB9) ---------------------------------------------//
|
||||
GPIO_InitStructure.GPIO_Pin = OLED_RST_PIN;
|
||||
GPIO_InitStructure.GPIO_Pin = OLED_RST_PIN|GPIO_Pin_12;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
@@ -100,6 +100,7 @@ void GPIO_Config(void) {
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //pullup just in case something resets the accel
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
GPIO_ResetBits(GPIOA, GPIO_Pin_12);//Write PA12 low so USB does not enumerate
|
||||
}
|
||||
/*
|
||||
* Init the ADC's
|
||||
|
||||
@@ -78,7 +78,7 @@ int I2C_Master_Read(uint8_t deviceAddr, uint8_t readAddr, uint8_t* pBuffer,
|
||||
uint16_t numByteToRead) {
|
||||
|
||||
__IO uint32_t temp = 0;
|
||||
volatile int I2C_TimeOut = 0;
|
||||
volatile int I2C_TimeOut = temp;
|
||||
|
||||
// /* While the bus is busy * /
|
||||
I2C_TimeOut = 1000;
|
||||
|
||||
@@ -20,6 +20,7 @@ int main(void) {
|
||||
Clear_Watchdog(); //reset the Watch dog timer
|
||||
ProcessUI();
|
||||
DrawUI();
|
||||
OLED_Sync();//Write out the screen buffer
|
||||
delayMs(15); //Slow the system down waiting for the iron.
|
||||
|
||||
if (systemSettings.OrientationMode == 2) {
|
||||
@@ -60,7 +61,8 @@ void setup() {
|
||||
else
|
||||
Init_Oled(systemSettings.OrientationMode); //Init the OLED display
|
||||
|
||||
OLED_DrawString("VER 1.16", 8); //Version Number
|
||||
OLED_DrawString("Ver 1.17", 8); //Version Number
|
||||
OLED_Sync();
|
||||
delayMs(400); //Pause to show version number
|
||||
showBootLogoIfavailable();
|
||||
//RESETs settings
|
||||
|
||||
@@ -33,8 +33,7 @@ void ProcessUI() {
|
||||
}
|
||||
break;
|
||||
case SOLDERING:
|
||||
if ((millis() - getLastButtonPress()) < 250)
|
||||
Buttons = 0;
|
||||
|
||||
//^ This is to make the button more delayed in timing for people to find A+B easier
|
||||
//We need to check the buttons if we need to jump out
|
||||
if ((Buttons == BUT_A && !systemSettings.boostModeEnabled)
|
||||
@@ -221,6 +220,10 @@ void ProcessUI() {
|
||||
case AUTOSTART:
|
||||
systemSettings.autoStart = !systemSettings.autoStart;
|
||||
break;
|
||||
case COOLINGBLINK:
|
||||
systemSettings.coolingTempBlink =
|
||||
!systemSettings.coolingTempBlink;
|
||||
break;
|
||||
#ifdef PIDTUNING
|
||||
case PIDP:
|
||||
pidSettings.kp++;
|
||||
@@ -437,17 +440,18 @@ void DrawUI() {
|
||||
else if (systemSettings.displayUpdateSpeed == DISPLAYMODE_MEDIUM
|
||||
&& (millis() - lastOLEDDrawTime < 100))
|
||||
return;
|
||||
else if (systemSettings.displayUpdateSpeed == DISPLAYMODE_FAST
|
||||
&& (millis() - lastOLEDDrawTime < 50))
|
||||
return;
|
||||
|
||||
Clear_Screen();
|
||||
|
||||
uint32_t tempavg = (temp + lastSolderingDrawnTemp1
|
||||
+ lastSolderingDrawnTemp2);
|
||||
tempavg /= 3;
|
||||
|
||||
drawTemp(tempavg, 0, systemSettings.temperatureRounding);
|
||||
lastSolderingDrawnTemp1 = temp;
|
||||
lastSolderingDrawnTemp2 = lastSolderingDrawnTemp1;
|
||||
lastOLEDDrawTime = millis();
|
||||
|
||||
//Now draw symbols
|
||||
if (StatusFlags == 8)
|
||||
OLED_DrawChar('B', 4);
|
||||
@@ -469,9 +473,8 @@ void DrawUI() {
|
||||
if (cellV > 9)
|
||||
cellV = 9;
|
||||
OLED_DrawExtendedChar(cellV + 1, 5);
|
||||
} else {
|
||||
OLED_DrawChar(' ', 5);
|
||||
}
|
||||
|
||||
if (systemSettings.displayTempInF) {
|
||||
OLED_DrawChar(SettingTempFChar, 3);
|
||||
} else {
|
||||
@@ -487,7 +490,6 @@ void DrawUI() {
|
||||
OLED_DrawWideChar((count), 6);
|
||||
} else {
|
||||
//Draw in the arrows if the user has the power display turned off
|
||||
OLED_BlankSlot(6 * 12 + 16, 24 - 16);//blank out the tail after the arrows
|
||||
if (getIronTimer() == 0
|
||||
&& (temp / 10) > (systemSettings.SolderingTemp / 10)) {
|
||||
//Cooling
|
||||
@@ -665,6 +667,17 @@ void DrawUI() {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case COOLINGBLINK:
|
||||
OLED_DrawString(SettingsShortNames[COOLINGBLINK], 7);
|
||||
switch (systemSettings.coolingTempBlink) {
|
||||
case 1:
|
||||
OLED_DrawChar(SettingTrueChar, 7);
|
||||
break;
|
||||
case 0:
|
||||
OLED_DrawChar(SettingFalseChar, 7);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#ifdef PIDTUNING
|
||||
case PIDP:
|
||||
OLED_DrawString("PIDP ", 5);
|
||||
@@ -688,9 +701,9 @@ void DrawUI() {
|
||||
case SLEEP:
|
||||
//The iron is in sleep temp mode
|
||||
//Draw in temp and sleep
|
||||
Clear_Screen();
|
||||
OLED_DrawString("SLP ", 4);
|
||||
drawTemp(temp, 4, systemSettings.temperatureRounding);
|
||||
OLED_BlankSlot(84, 96 - 85); //blank out after the temp
|
||||
|
||||
if (millis() - getLastMovement() > (10 * 60 * 1000)
|
||||
&& (millis() - getLastButtonPress() > (10 * 60 * 1000))) {
|
||||
@@ -703,9 +716,12 @@ void DrawUI() {
|
||||
break;
|
||||
case COOLING:
|
||||
//We are warning the user the tip is cooling
|
||||
Clear_Screen();
|
||||
OLED_DrawString(CoolingPromptString, 5);
|
||||
temp = readIronTemp(0, 1, 0xFFFF); //force temp re-reading
|
||||
drawTemp(temp, 5, systemSettings.temperatureRounding);
|
||||
if (temp < 500 || ((millis() % 1000) > 500))
|
||||
drawTemp(temp, 5, systemSettings.temperatureRounding);
|
||||
|
||||
break;
|
||||
case UVLOWARN:
|
||||
OLED_DrawString(UVLOWarningString, 8);
|
||||
@@ -721,12 +737,12 @@ void DrawUI() {
|
||||
if (StatusFlags == 0 || ((millis() % 1000) > 500)) {
|
||||
|
||||
OLED_DrawString("IN", 2);
|
||||
OLED_DrawChar(48+((voltage / 100) % 10), 2);
|
||||
OLED_DrawChar(48 + ((voltage / 100) % 10), 2);
|
||||
voltage -= (voltage / 100) * 100;
|
||||
OLED_DrawChar(48+((voltage / 10) % 10), 3);
|
||||
OLED_DrawChar(48 + ((voltage / 10) % 10), 3);
|
||||
voltage -= (voltage / 10) * 10;
|
||||
OLED_DrawChar('.', 4);
|
||||
OLED_DrawChar(48+(voltage % 10), 5);
|
||||
OLED_DrawChar(48 + (voltage % 10), 5);
|
||||
OLED_DrawChar('V', 6);
|
||||
OLED_DrawChar(' ', 7);
|
||||
} else {
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
#include "Font.h"
|
||||
int8_t displayOffset = 32;
|
||||
uint8_t currentOrientation = 0;
|
||||
|
||||
uint8_t displayBuffer[2 * 96]; //This is used to allow us to draw locally before sync'ing to the screen.
|
||||
|
||||
/*Setup params for the OLED screen*/
|
||||
/*http://www.displayfuture.com/Display/datasheet/controller/SSD1307.pdf*/
|
||||
/*All commands are prefixed with 0x80*/
|
||||
@@ -74,7 +77,7 @@ const u8* Data_Command(u8 length, const u8* data) {
|
||||
//here are are inserting the data write command at the beginning
|
||||
tx_data[0] = 0x40;
|
||||
length++;
|
||||
for (i = 1; i < length; i++) //Loop through the array of data
|
||||
for (i = 1; i <= length; i++) //Loop through the array of data
|
||||
{
|
||||
if (data == 0)
|
||||
tx_data[i] = 0;
|
||||
@@ -84,6 +87,14 @@ const u8* Data_Command(u8 length, const u8* data) {
|
||||
I2C_PageWrite(tx_data, length, DEVICEADDR_OLED); //write out the buffer
|
||||
return data;
|
||||
}
|
||||
//This causes us to write out the buffered screen data to the display
|
||||
void OLED_Sync() {
|
||||
Set_ShowPos(0,0);
|
||||
Data_Command(96, displayBuffer);
|
||||
Set_ShowPos(0,1);
|
||||
Data_Command(96, displayBuffer + 96);
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
Function:Set_ShowPos
|
||||
Description:Set the current position in GRAM that we are drawing to
|
||||
@@ -103,25 +114,21 @@ void Set_ShowPos(u8 x, u8 y) {
|
||||
Inputs:(x,y) start point, (width,height) of enclosing rect, pointer to data
|
||||
Output: pointer to the last byte written out
|
||||
*******************************************************************************/
|
||||
const u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high, const u8* ptr) {
|
||||
u8 m, n, y;
|
||||
|
||||
n = y0 + high;
|
||||
if (y0 % 8 == 0)
|
||||
m = y0 / 8;
|
||||
else
|
||||
m = y0 / 8 + 1;
|
||||
|
||||
if (n % 8 == 0)
|
||||
y = n / 8;
|
||||
else
|
||||
y = n / 8 + 1;
|
||||
|
||||
for (; m < y; m++) {
|
||||
Set_ShowPos(x0, m);
|
||||
ptr = Data_Command(wide, ptr);
|
||||
void Oled_DrawArea(u8 x, u8 y, u8 wide, u8 height, const u8* ptr) {
|
||||
//We want to blat the given data over the buffer
|
||||
//X is the left right position (index's through the display buffer)
|
||||
//Y is the height value (affects the bits)
|
||||
//Y is either 0 or 8, we dont do smaller bit blatting
|
||||
u8 lines = height / 8;
|
||||
//We draw the 1 or two stripes seperately
|
||||
for (u8 i = 0; i < (wide * lines); i++) {
|
||||
u8 xp = x + (i % wide);
|
||||
u8 yoffset = i < wide ? 0 : 96;
|
||||
if (y == 8)
|
||||
yoffset = 96;
|
||||
displayBuffer[xp + yoffset] = ptr[i];
|
||||
}
|
||||
return ptr;
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -159,6 +166,8 @@ void Init_Oled(uint8_t leftHanded) {
|
||||
displayOffset = 32;
|
||||
}
|
||||
I2C_PageWrite((u8 *) OLED_Setup_Array, param_len, DEVICEADDR_OLED);
|
||||
for (uint8_t i = 0; i < 2 * 96; i++)
|
||||
displayBuffer[i] = 0; //turn off screen
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -166,11 +175,8 @@ void Init_Oled(uint8_t leftHanded) {
|
||||
Description:Clear the entire screen to off (black)
|
||||
*******************************************************************************/
|
||||
void Clear_Screen(void) {
|
||||
u8 tx_data[128];
|
||||
memset(tx_data, 0, 128);
|
||||
for (u8 i = 0; i < 2; i++) {
|
||||
Oled_DrawArea(0, i * 8, 128, 8, tx_data);
|
||||
}
|
||||
memset(displayBuffer, 0, 96 * 2);
|
||||
|
||||
}
|
||||
/*
|
||||
* Draws a string onto the screen starting at the left
|
||||
|
||||
@@ -74,6 +74,7 @@ void resetSettings() {
|
||||
systemSettings.BoostTemp = 4000; //default to 400C
|
||||
systemSettings.powerDisplay = 0; //default to power display being off
|
||||
systemSettings.autoStart = 0; //Auto start off for safety
|
||||
systemSettings.coolingTempBlink = 0; //Blink the temperature on the cooling screen when its > 50C
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
@@ -112,6 +113,6 @@ void showBootLogoIfavailable() {
|
||||
return;
|
||||
|
||||
Oled_DrawArea(0, 0, 96, 16, (uint8_t*) (temp8 + 4));
|
||||
|
||||
OLED_Sync();
|
||||
delayMs(1000);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "Strings.h"
|
||||
#define LANG_EN
|
||||
#ifdef LANG_EN
|
||||
const char* SettingsLongNames[13] =
|
||||
const char* SettingsLongNames[14] =
|
||||
{
|
||||
/*These are all the help text for all the settings.*/
|
||||
/*All must start with 6 spaces so they come on screen nicely.*/
|
||||
@@ -21,10 +21,11 @@ const char* SettingsLongNames[13] =
|
||||
" Enable front key boost 450C mode when soldering",
|
||||
" Temperature when in boost mode",
|
||||
" Changes the arrows to a power display when soldering",
|
||||
" Automatically starts the iron into soldering on power up." };
|
||||
" Automatically starts the iron into soldering on power up.",
|
||||
" Blink the temperature on the cooling screen while the tip is still hot." };
|
||||
|
||||
const char* TempCalStatus[3] = { "CAL TEMP", "CAL OK ", "CAL FAIL" }; //All fixed 8 chars
|
||||
const char* UVLOWarningString = "LOW VOLT"; //Fixed width 8 chars
|
||||
const char* TempCalStatus[3] = { "Cal Temp", "Cal OK ", "Cal Fail" }; //All fixed 8 chars
|
||||
const char* UVLOWarningString = "Low Volt"; //Fixed width 8 chars
|
||||
const char* CoolingPromptString = "COOL "; //Fixed width 5 chars
|
||||
const char SettingTrueChar = 'T';
|
||||
const char SettingFalseChar = 'F';
|
||||
@@ -39,7 +40,7 @@ const char SettingTempFChar = 'F';
|
||||
|
||||
#endif
|
||||
#ifdef LANG_ES
|
||||
const char* SettingsLongNames[13] =
|
||||
const char* SettingsLongNames[14] =
|
||||
{
|
||||
/*These are all the help text for all the settings.*/
|
||||
/*All must start with 6 spaces so they come on screen nicely.*/
|
||||
@@ -53,7 +54,8 @@ const char* SettingsLongNames[13] =
|
||||
" Activar el boton <Boost> en modo soldadura.",
|
||||
" Temperatura en modo <Boost>.",
|
||||
" Cambiar las flechas en pantalla por indicador de potencia en modo soldadura.",
|
||||
" Iniciar directamente modo soldadura en el encendido."};
|
||||
" Iniciar directamente modo soldadura en el encendido.",
|
||||
" Blink the temperature on the cooling screen while the tip is still hot."};/*Needs translation*/
|
||||
|
||||
const char* TempCalStatus[3] = {"CAL TEMP", "CAL OK ", "CAL FAIL"}; //All fixed 8 chars
|
||||
const char* UVLOWarningString = "LOW VOLT";//Fixed width 8 chars
|
||||
@@ -70,6 +72,6 @@ const char SettingTempCChar = 'C';
|
||||
const char SettingTempFChar = 'F';
|
||||
#endif
|
||||
|
||||
const char* SettingsShortNames[13] = { "PWRSC ", "STMP ", "SLTME ", "SHTME ",
|
||||
const char* SettingsShortNames[14] = { "PWRSC ", "STMP ", "SLTME ", "SHTME ",
|
||||
"MSENSE ", "TMPUNT ", "TMPRND ", "TMPSPD ", "DSPROT ", "BOOST ",
|
||||
"BTMP ", "PWRDSP ", "ASTART " };
|
||||
"BTMP ", "PWRDSP ", "ASTART ", "CLBLNK " };
|
||||
|
||||
Reference in New Issue
Block a user