Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d1d47acee | ||
|
|
e598d1cbbb | ||
|
|
20d1874aee | ||
|
|
030a714ff2 | ||
|
|
67066f218f | ||
|
|
50fe2bcff1 | ||
|
|
a576f44ba2 | ||
|
|
74de59c235 | ||
|
|
fc669dc274 | ||
|
|
b0b512030f | ||
|
|
48cc1ff8cc | ||
|
|
c9a56392a0 | ||
|
|
b6b207568c | ||
|
|
8bf65351ea | ||
|
|
215fe8e9e8 | ||
|
|
4718efe79b | ||
|
|
771f0a1b9e | ||
|
|
1fef2fb53a | ||
|
|
bf1fa74d72 | ||
|
|
1ae8b2f216 | ||
|
|
98ed6be197 | ||
|
|
19240f2ae5 | ||
|
|
dd2fdbcb8e | ||
|
|
42db57da25 | ||
|
|
b6351f9696 | ||
|
|
bf7f1f5062 | ||
|
|
6500eb5eed | ||
|
|
311d5182eb | ||
|
|
88ea45d8c8 | ||
|
|
576575d7ba | ||
|
|
7c1937b412 | ||
|
|
f599624b6f | ||
|
|
cc09157106 | ||
|
|
586267f586 |
@@ -34,36 +34,36 @@ ADC1.SamplingTime-4\#ChannelInjectedConversion=ADC_SAMPLETIME_239CYCLES_5
|
||||
ADC1.SamplingTime-5\#ChannelInjectedConversion=ADC_SAMPLETIME_71CYCLES_5
|
||||
ADC1.ScanConvMode=ADC_SCAN_ENABLE
|
||||
ADC1.master=1
|
||||
Dma.ADC1.2.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.ADC1.2.Instance=DMA1_Channel1
|
||||
Dma.ADC1.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
|
||||
Dma.ADC1.2.MemInc=DMA_MINC_ENABLE
|
||||
Dma.ADC1.2.Mode=DMA_CIRCULAR
|
||||
Dma.ADC1.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
|
||||
Dma.ADC1.2.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.ADC1.2.Priority=DMA_PRIORITY_VERY_HIGH
|
||||
Dma.ADC1.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
Dma.I2C1_RX.0.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.I2C1_RX.0.Instance=DMA1_Channel7
|
||||
Dma.I2C1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.I2C1_RX.0.MemInc=DMA_MINC_ENABLE
|
||||
Dma.I2C1_RX.0.Mode=DMA_NORMAL
|
||||
Dma.I2C1_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.I2C1_RX.0.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.I2C1_RX.0.Priority=DMA_PRIORITY_LOW
|
||||
Dma.I2C1_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
Dma.I2C1_TX.1.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Dma.I2C1_TX.1.Instance=DMA1_Channel6
|
||||
Dma.I2C1_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.I2C1_TX.1.MemInc=DMA_MINC_ENABLE
|
||||
Dma.I2C1_TX.1.Mode=DMA_NORMAL
|
||||
Dma.I2C1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.I2C1_TX.1.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.I2C1_TX.1.Priority=DMA_PRIORITY_LOW
|
||||
Dma.I2C1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
Dma.Request0=I2C1_RX
|
||||
Dma.Request1=I2C1_TX
|
||||
Dma.Request2=ADC1
|
||||
Dma.ADC1.0.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.ADC1.0.Instance=DMA1_Channel1
|
||||
Dma.ADC1.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
|
||||
Dma.ADC1.0.MemInc=DMA_MINC_ENABLE
|
||||
Dma.ADC1.0.Mode=DMA_CIRCULAR
|
||||
Dma.ADC1.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
|
||||
Dma.ADC1.0.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.ADC1.0.Priority=DMA_PRIORITY_VERY_HIGH
|
||||
Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
Dma.I2C1_RX.1.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.I2C1_RX.1.Instance=DMA1_Channel7
|
||||
Dma.I2C1_RX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.I2C1_RX.1.MemInc=DMA_MINC_ENABLE
|
||||
Dma.I2C1_RX.1.Mode=DMA_NORMAL
|
||||
Dma.I2C1_RX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.I2C1_RX.1.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.I2C1_RX.1.Priority=DMA_PRIORITY_MEDIUM
|
||||
Dma.I2C1_RX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
Dma.I2C1_TX.2.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Dma.I2C1_TX.2.Instance=DMA1_Channel6
|
||||
Dma.I2C1_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.I2C1_TX.2.MemInc=DMA_MINC_ENABLE
|
||||
Dma.I2C1_TX.2.Mode=DMA_NORMAL
|
||||
Dma.I2C1_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.I2C1_TX.2.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.I2C1_TX.2.Priority=DMA_PRIORITY_MEDIUM
|
||||
Dma.I2C1_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
Dma.Request0=ADC1
|
||||
Dma.Request1=I2C1_RX
|
||||
Dma.Request2=I2C1_TX
|
||||
Dma.RequestsNb=3
|
||||
FREERTOS.FootprintOK=true
|
||||
FREERTOS.INCLUDE_vTaskDelete=0
|
||||
@@ -74,8 +74,9 @@ FREERTOS.configMINIMAL_STACK_SIZE=256
|
||||
FREERTOS.configTICK_RATE_HZ=100
|
||||
FREERTOS.configTOTAL_HEAP_SIZE=10240
|
||||
File.Version=6
|
||||
I2C1.DutyCycle=I2C_DUTYCYCLE_2
|
||||
I2C1.I2C_Mode=I2C_Fast
|
||||
I2C1.IPParameters=I2C_Mode
|
||||
I2C1.IPParameters=I2C_Mode,DutyCycle
|
||||
IWDG.IPParameters=Prescaler
|
||||
IWDG.Prescaler=IWDG_PRESCALER_256
|
||||
KeepUserPlacement=false
|
||||
@@ -88,8 +89,9 @@ Mcu.IP4=IWDG
|
||||
Mcu.IP5=NVIC
|
||||
Mcu.IP6=RCC
|
||||
Mcu.IP7=SYS
|
||||
Mcu.IP8=TIM3
|
||||
Mcu.IPNb=9
|
||||
Mcu.IP8=TIM2
|
||||
Mcu.IP9=TIM3
|
||||
Mcu.IPNb=10
|
||||
Mcu.Name=STM32F103T(8-B)Ux
|
||||
Mcu.Package=VFQFPN36
|
||||
Mcu.Pin0=PA6
|
||||
@@ -100,9 +102,12 @@ Mcu.Pin12=PB7
|
||||
Mcu.Pin13=VP_FREERTOS_VS_ENABLE
|
||||
Mcu.Pin14=VP_IWDG_VS_IWDG
|
||||
Mcu.Pin15=VP_SYS_VS_tim1
|
||||
Mcu.Pin16=VP_TIM3_VS_ClockSourceINT
|
||||
Mcu.Pin17=VP_TIM3_VS_no_output4
|
||||
Mcu.Pin16=VP_TIM2_VS_ClockSourceINT
|
||||
Mcu.Pin17=VP_TIM2_VS_no_output1
|
||||
Mcu.Pin18=VP_TIM2_VS_no_output3
|
||||
Mcu.Pin19=VP_TIM3_VS_ClockSourceINT
|
||||
Mcu.Pin2=PB0
|
||||
Mcu.Pin20=VP_TIM3_VS_no_output4
|
||||
Mcu.Pin3=PB1
|
||||
Mcu.Pin4=PA8
|
||||
Mcu.Pin5=PA9
|
||||
@@ -110,28 +115,31 @@ Mcu.Pin6=PA13
|
||||
Mcu.Pin7=PA14
|
||||
Mcu.Pin8=PB3
|
||||
Mcu.Pin9=PB4
|
||||
Mcu.PinsNb=18
|
||||
Mcu.PinsNb=21
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32F103T8Ux
|
||||
MxCube.Version=4.22.0
|
||||
MxDb.Version=DB.4.0.220
|
||||
NVIC.ADC1_2_IRQn=true\:5\:0\:false\:false\:true\:true
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.DMA1_Channel1_IRQn=true\:5\:0\:false\:false\:true\:true
|
||||
NVIC.DMA1_Channel6_IRQn=true\:5\:0\:false\:false\:true\:true
|
||||
NVIC.DMA1_Channel7_IRQn=true\:5\:0\:false\:false\:true\:true
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true
|
||||
MxCube.Version=4.25.0
|
||||
MxDb.Version=DB.4.0.250
|
||||
NVIC.ADC1_2_IRQn=true\:5\:0\:false\:false\:true\:true\:true
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:true
|
||||
NVIC.DMA1_Channel1_IRQn=true\:5\:0\:false\:false\:true\:true\:true
|
||||
NVIC.DMA1_Channel6_IRQn=true\:5\:0\:false\:false\:true\:true\:true
|
||||
NVIC.DMA1_Channel7_IRQn=true\:5\:0\:false\:false\:true\:true\:true
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:true
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:true
|
||||
NVIC.I2C1_ER_IRQn=true\:5\:0\:false\:false\:true\:true\:true
|
||||
NVIC.I2C1_EV_IRQn=true\:5\:0\:false\:false\:true\:true\:true
|
||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:true
|
||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:true
|
||||
NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true
|
||||
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false
|
||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true
|
||||
NVIC.TIM1_UP_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true
|
||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true
|
||||
NVIC.TIM1_UP_IRQn=true\:0\:0\:false\:false\:true\:false\:true
|
||||
NVIC.TimeBase=TIM1_UP_IRQn
|
||||
NVIC.TimeBaseIP=TIM1
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:true
|
||||
PA13.Locked=true
|
||||
PA13.Mode=Serial_Wire
|
||||
PA13.Signal=SYS_JTMS-SWDIO
|
||||
@@ -193,29 +201,30 @@ PCC.Vdd=3.3
|
||||
PinOutPanel.RotationAngle=0
|
||||
ProjectManager.AskForMigrate=true
|
||||
ProjectManager.BackupPrevious=false
|
||||
ProjectManager.CompilerOptimize=2
|
||||
ProjectManager.CompilerOptimize=3
|
||||
ProjectManager.ComputerToolchain=false
|
||||
ProjectManager.CoupleFile=false
|
||||
ProjectManager.CustomerFirmwarePackage=C\:/Users/Ben V. Brown/STM32Cube/Repository/STM32Cube_FW_F1_V1.6.0
|
||||
ProjectManager.CustomerFirmwarePackage=C\:/Users/Ralim/STM32Cube/Repository/STM32Cube_FW_F1_V1.6.1
|
||||
ProjectManager.DefaultFWLocation=true
|
||||
ProjectManager.DeletePrevious=true
|
||||
ProjectManager.DeviceId=STM32F103T8Ux
|
||||
ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.6.0
|
||||
ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.6.1
|
||||
ProjectManager.FreePins=true
|
||||
ProjectManager.HalAssertFull=false
|
||||
ProjectManager.HeapSize=0x200
|
||||
ProjectManager.KeepUserCode=true
|
||||
ProjectManager.LastFirmware=true
|
||||
ProjectManager.LibraryCopy=1
|
||||
ProjectManager.MainLocation=Src
|
||||
ProjectManager.PreviousToolchain=SW4STM32
|
||||
ProjectManager.ProjectBuild=false
|
||||
ProjectManager.ProjectFileName=TS100.ioc
|
||||
ProjectManager.ProjectName=TS100
|
||||
ProjectManager.StackSize=0x400
|
||||
ProjectManager.TargetToolchain=SW4STM32
|
||||
ProjectManager.ToolChainLocation=C\:\\Users\\Ralim\\Repo\\ts100\\TS100
|
||||
ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UnderRoot=false
|
||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL,2-MX_DMA_Init-DMA-false-HAL,3-MX_I2C1_Init-I2C1-false-HAL,4-MX_ADC1_Init-ADC1-false-HAL,5-SystemClock_Config-RCC-false-HAL,6-MX_TIM3_Init-TIM3-false-HAL,7-MX_IWDG_Init-IWDG-false-HAL
|
||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_I2C1_Init-I2C1-false-HAL-true,4-MX_ADC1_Init-ADC1-false-HAL-true,5-SystemClock_Config-RCC-false-HAL-true,6-MX_TIM3_Init-TIM3-false-HAL-true,7-MX_IWDG_Init-IWDG-false-HAL-true,8-MX_TIM2_Init-TIM2-false-HAL-true
|
||||
RCC.ADCFreqValue=8000000
|
||||
RCC.ADCPresc=RCC_ADCPCLK2_DIV8
|
||||
RCC.AHBFreq_Value=64000000
|
||||
@@ -252,6 +261,9 @@ SH.GPXTI5.0=GPIO_EXTI5
|
||||
SH.GPXTI5.ConfNb=1
|
||||
SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1
|
||||
SH.S_TIM3_CH1.ConfNb=1
|
||||
TIM2.Channel-PWM\ Generation1\ No\ Output=TIM_CHANNEL_1
|
||||
TIM2.Channel-PWM\ Generation3\ No\ Output=TIM_CHANNEL_3
|
||||
TIM2.IPParameters=Channel-PWM Generation1 No Output,Channel-PWM Generation3 No Output
|
||||
TIM3.Channel-Output\ Compare4\ No\ Output=TIM_CHANNEL_4
|
||||
TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
|
||||
TIM3.ClockDivision=TIM_CLOCKDIVISION_DIV4
|
||||
@@ -267,6 +279,12 @@ VP_IWDG_VS_IWDG.Mode=IWDG_Activate
|
||||
VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG
|
||||
VP_SYS_VS_tim1.Mode=TIM1
|
||||
VP_SYS_VS_tim1.Signal=SYS_VS_tim1
|
||||
VP_TIM2_VS_ClockSourceINT.Mode=Internal
|
||||
VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
|
||||
VP_TIM2_VS_no_output1.Mode=PWM Generation1 No Output
|
||||
VP_TIM2_VS_no_output1.Signal=TIM2_VS_no_output1
|
||||
VP_TIM2_VS_no_output3.Mode=PWM Generation3 No Output
|
||||
VP_TIM2_VS_no_output3.Signal=TIM2_VS_no_output3
|
||||
VP_TIM3_VS_ClockSourceINT.Mode=Internal
|
||||
VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT
|
||||
VP_TIM3_VS_no_output4.Mode=Output Compare4 No Output
|
||||
|
||||
62
README.md
62
README.md
@@ -1,10 +1,12 @@
|
||||
# TS100
|
||||
|
||||
This is a complete rewrite of the open source software for the ts100 soldering iron.
|
||||
The version two fork of this code has no shared code with the original firmware from Miniware (E-design) group.
|
||||
This project is concidered feature complete for use as a soldering iron, *so please suggest any feature improvements you would like!*
|
||||
|
||||
A short(ish) video that goes through every single menu option in the firmware is available [over here](https://www.youtube.com/watch?v=WlnpboYfxNk).
|
||||
This video was created on an earlier 1.x version of the firmware, so alot has changed and a new video will be coming soon for the 2.x fork.
|
||||
This project is considered feature complete for use as a soldering iron, *so please suggest any feature improvements you would like!*
|
||||
|
||||
A short(ish) video that goes through every single menu option in the firmware is available [over here](https://www.youtube.com/watch?v=WlnpboYfxNk).
|
||||
This video was created on an earlier 1.x version of the firmware, so alot has changed but should be fairly intuitive as the menu has vastly improved.
|
||||
|
||||
*This firmware does **NOT** support the usb port while running for changing settings. This is done through the onscreen menu only. Logos are edited using the tool or python script and uploaded in DFU mode.*
|
||||
|
||||
@@ -12,6 +14,7 @@ This video was created on an earlier 1.x version of the firmware, so alot has ch
|
||||
Please calibrate your irons voltage reading when you are using a lithium battery after any firmware upgrades.*
|
||||
|
||||
## Features
|
||||
|
||||
* PID iron temperature control
|
||||
* Automatic sleep with selectable sensitivity
|
||||
* Motion wake support
|
||||
@@ -26,10 +29,11 @@ Please calibrate your irons voltage reading when you are using a lithium battery
|
||||
* Battery charge level indicatior if power source set to a lipo cell count.
|
||||
* Custom bootup logo support
|
||||
* Automatic LCD rotation based on orientation
|
||||
* Supports both the version 1 and version 2 hardware
|
||||
|
||||
## Upgrading your ts100 iron
|
||||
|
||||
This is completely safe, if it goes wrong just put the .hex file from the official website onto the unit and your back to the old firmware. Downloads for the hex files to flash are available on the [releases page.](https://github.com/Ralim/ts100/releases) The file you want is called *ts100.hex* unless you want the translations, they are ts100_*language short name*.hex.
|
||||
This is completely safe, if it goes wrong just put the .hex file from the official website onto the unit and your back to the old firmware. Downloads for the hex files to flash are available on the [releases page.](https://github.com/Ralim/ts100/releases) The file you want is called *ts100_EN.hex* unless you want the translations, they are ts100_*language short name*.hex.
|
||||
|
||||
Officially the bootloader on the iron only works under windows. However, users have reported that it does work under Mac, and can be made to work under Linux *sometimes*. Details over on the [wiki page](https://github.com/Ralim/ts100/wiki/Upgrading-Firmware).
|
||||
|
||||
@@ -55,13 +59,15 @@ There are further instructions on the [wiki](https://github.com/Ralim/ts100/wiki
|
||||
|
||||
This new firmware uses a new menu system to allow access to the settings on the device.
|
||||
When on the main screen, the unit shows prompts for the two most common operations.
|
||||
|
||||
* Pressing the button near the tip enters soldering mode
|
||||
* Pressing the button near the USB enters the settings menu.
|
||||
* Holding the button near the tip will enter soldering temperature adjust mode (This is the same as the one in the soldering menu, just to let you edit before heating up).
|
||||
* Holding the button near the USB end will show the firmware version details.
|
||||
|
||||
## Soldering mode
|
||||
|
||||
In this mode the iron works as you would expect, pressing either button will take you to a temperature change screen.
|
||||
In this mode the iron works as you would expect, pressing either button will take you to a temperature change screen.
|
||||
Use each button to go up and down in temperature. Pressing both buttons will exit you from the temperature menu (or wait 3 seconds and it will time out).
|
||||
Pressing both buttons or holding the button near the USB will exit the soldering mode.
|
||||
Holding the button at the front of the iron will enter boost mode (if enabled).
|
||||
@@ -70,28 +76,17 @@ Holding the button at the front of the iron will enter boost mode (if enabled).
|
||||
|
||||
This menu allows you to cycle through all the options and set their values.
|
||||
The button near the USB cycles through the options, and the one near the tip changes the selected option.
|
||||
Note that settings are not saved until you exit the menu, and some settings such as screen flip do not apply until a power cycle is applied.
|
||||
If you leave the unit alone (ie don't press any buttons) on a setting, after 3 seconds the screen will scroll a longer version of the name
|
||||
Note that settings are not saved until you exit the menu.
|
||||
If you leave the unit alone (ie don't press any buttons) on a setting, after 3 seconds the screen will scroll a rough description of the setting.
|
||||
|
||||
* PWRSC -> Power source, select a cell count if using a LiPo, or DC to disable the shutdown. (Sets it to minimum of 10V).
|
||||
* STMP -> The temperature the unit drops to in sleep mode
|
||||
* SLTME -> Sleep time, how long it takes before the unit goes to sleep
|
||||
* SHTME -> Shutdown Time, how long the unit will wait after movement before shutting down completely
|
||||
* MSENSE -> Motion Sensitivity,0*9,0 means motion sensing is turned off, 9 is most sensitive, 1 is least sensitive (ie takes more movement to trigger)
|
||||
* ADVDSP -> Enable the advanced display (shows more details)
|
||||
* DSPROT -> Display rotation mode, Automatic, Left handed or Right handed
|
||||
* BOOST -> Enable boost mode
|
||||
* BTMP -> Set the temperature for the boost mode
|
||||
* ASART -> Automatically start the unit when power is applied (i.e. the unit will go straight into soldering mode)
|
||||
* CLBLNK -> Blink the screen as an alert when cooling down
|
||||
* TMP CAL -> Use to calibrate offset on the tip temperature
|
||||
* RESET -> Use to force a complete reset on exit of the settings menu
|
||||
* TMPUNIT -> Temperature unit, C or F
|
||||
The menu is arranged so that the most often used settings are first.
|
||||
With submenu's being selected to enter using the front button (as if you were going to change the setting).
|
||||
Scrolling through the submenu will return you back to its entry location after you scroll through all of the options.
|
||||
|
||||
### Calibrating input voltage
|
||||
|
||||
Due to the tolerance on the resistors used for the input voltage divider, some irons can be up to 0.6V out on the voltage measurement.
|
||||
Please calibrate your iron if you have any issues with the cutoff voltage.
|
||||
Please calibrate your iron if you have any issues with the cutoff voltage.
|
||||
Note that cutoff messages can also be triggered by using a power supply that is too weak and fails under the load of the iron.
|
||||
This is more critical than before with the new cell count based cutout voltage.
|
||||
|
||||
@@ -99,19 +94,11 @@ To calibrate your Iron:
|
||||
|
||||
1. Measure the input voltage with a multimeter and note it down.
|
||||
2. Connect the input to your iron.
|
||||
3. On the home screen (showing iron symbol), press both buttons simultainiously.
|
||||
4. The iron will now show the tip temperature.
|
||||
5. Press the button near the soldering iron tip.
|
||||
6. The screen will display the measured input voltage.
|
||||
7. If this is the same as what you measured before skip to step 13
|
||||
8. Otherwise, press the button near the USB end of the iron
|
||||
9. The voltage will now slowly blink.
|
||||
10. Use the buttons to adjust the reading up and down until it reads as close as possible to the voltage you measured earlier.
|
||||
11. When it is reading as close as possible, press both buttons at once.
|
||||
12. The screen will go back to just showing the input voltage.
|
||||
13. Press the button near the tip of the iron to exit back to the live temperature display.
|
||||
14. Press both buttons at once to exit back to the idle screen.
|
||||
15. You're done. Enjoy your iron.
|
||||
3. Enter the settings menu
|
||||
4. Under the advanced submenu
|
||||
5. Select the calibrate voltage option
|
||||
6. Use the front and back buttons to adjust the displayed voltage to minimise the error to your origional measurement
|
||||
7. Hold both buttons to save and exit to the menu
|
||||
|
||||
### Calibrating tip offset
|
||||
|
||||
@@ -120,13 +107,13 @@ Some tips will have an offset on their readings, to calibrate this out perform t
|
||||
1. Connect power to your iron
|
||||
2. Make sure the tip is at room temperature (ie. wait for a fair while after using the iron before calibration)
|
||||
3. Enter the settings menu
|
||||
4. Scroll down to *TMP CAL*
|
||||
4. Scroll down to the advanced menu, and then the temperature calibration
|
||||
5. Press the button to change the option (tip button)
|
||||
6. The display will start to scroll a warning message to check that the tip is at ambient temperature!
|
||||
7. Press the button near the tip of the iron to confirm.
|
||||
8. The display will go to "...." for a short period of time as the unit measures the tip temperature and the handle temperature and compares them
|
||||
9. The display will then go back to *TMP CAL*
|
||||
10. Calibration is done, just exit the settings menu as normal
|
||||
10. Calibration is done, just exit the settings menu as normal
|
||||
11. You're done. Enjoy your iron.
|
||||
|
||||
### Boost mode
|
||||
@@ -135,7 +122,6 @@ This allows you to change the front key (one near the tip) to become a boost but
|
||||
|
||||
The boost temperature is set in the settings menu.
|
||||
|
||||
|
||||
## Thanks
|
||||
|
||||
If you love this firmware and want to continue my caffine addiction, you can do so here (or email me for other options) : https://paypal.me/RalimTek
|
||||
|
||||
@@ -110,120 +110,6 @@
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="fr.ac6.managedbuild.config.gnu.cross.exe.release.723264573">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="fr.ac6.managedbuild.config.gnu.cross.exe.release.723264573" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="fr.ac6.managedbuild.config.gnu.cross.exe.release.723264573" name="Release" parent="fr.ac6.managedbuild.config.gnu.cross.exe.release" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.bin"; arm-none-eabi-size -B "${BuildArtifactFileName}" ;arm-none-eabi-objcopy -O ihex "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.hex"">
|
||||
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.release.723264573." name="/" resourcePath="">
|
||||
<toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release.1456567544" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release">
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.mcu.67332574" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" useByScannerDiscovery="false" value="STM32F103T8Ux" valueType="string"/>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.board.1570943989" name="Board" superClass="fr.ac6.managedbuild.option.gnu.cross.board" useByScannerDiscovery="false" value="ts100" valueType="string"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="fr.ac6.managedbuild.targetPlatform.gnu.cross.793444160" isAbstract="false" osList="all" superClass="fr.ac6.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder buildPath="${workspace_loc:/TS100}/Release" id="fr.ac6.managedbuild.builder.gnu.cross.548236022" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="fr.ac6.managedbuild.builder.gnu.cross"/>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.1363306495" name="MCU GCC Compiler" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<option id="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level.1100266163" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.c.optimization.level.more" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.debugging.level.2139237845" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.1770182855" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/CMSIS/core""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/CMSIS/device""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/HAL_Driver/Inc/Legacy""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/HAL_Driver/Inc""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/include""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3""/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1423042308" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="STM32F103T8Ux"/>
|
||||
<listOptionValue builtIn="false" value="STM32F1"/>
|
||||
<listOptionValue builtIn="false" value="STM32"/>
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F103xB"/>
|
||||
<listOptionValue builtIn="false" value="USE_RTOS_SYSTICK"/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.dialect.std.356859384" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.c.compiler.dialect.default" valueType="enumerated"/>
|
||||
<option id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.fdata.1580070223" name="Place the data in their own section (-fdata-sections)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.fdata" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="gnu.c.compiler.option.misc.pic.1841660469" name="Position Independent Code (-fPIC)" superClass="gnu.c.compiler.option.misc.pic" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c.747173367" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s.1210653460" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s"/>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.1414722294" name="MCU G++ Compiler" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler">
|
||||
<option id="fr.ac6.managedbuild.gnu.cpp.compiler.option.optimization.level.1489744363" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.cpp.optimization.level.more" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.debugging.level.641509376" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.105977434" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/CMSIS/core""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/CMSIS/device""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/HAL_Driver/Inc/Legacy""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/HAL_Driver/Inc""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/include""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3""/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.preprocessor.def.158062035" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="STM32F103T8Ux"/>
|
||||
<listOptionValue builtIn="false" value="STM32F1"/>
|
||||
<listOptionValue builtIn="false" value="STM32"/>
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F103xB"/>
|
||||
<listOptionValue builtIn="false" value="USE_RTOS_SYSTICK"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.dialect.std.2101054556" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/>
|
||||
<option id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.fdata.1877154487" name="Place the data in their own section (-fdata-sections)" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.fdata" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp.688034595" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s.6473827" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s"/>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.1409185098" name="MCU GCC Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker"/>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.162825548" name="MCU G++ Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<option id="gnu.cpp.link.option.strip.459660118" name="Omit all symbol information (-s)" superClass="gnu.cpp.link.option.strip" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.gcsections.664103720" name="Discard unused sections (-Wl,--gc-sections)" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1735005640" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.archiver.907512577" name="MCU GCC Archiver" superClass="fr.ac6.managedbuild.tool.gnu.archiver"/>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.assembler.1906472572" name="MCU GCC Assembler" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler">
|
||||
<option id="gnu.both.asm.option.include.paths.1277819409" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/CMSIS/core""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/CMSIS/device""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/HAL_Driver/Inc/Legacy""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/HAL_Driver/Inc""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/include""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1588000933" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.assembler.input.1118741214" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.assembler.exe.release.63862661" name="MCU GCC Assembler" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler.exe.release">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.983697759" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.assembler.input.1721181053" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="Src/stm32f1xx_hal_timebase_tim_template.c|Src/stm32f1xx_hal_timebase_rtc_wakeup_template.c|Src/stm32f1xx_hal_timebase_rtc_alarm_template.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="HAL_Driver"/>
|
||||
<entry excluding="Third_Party/FreeRTOS/Source/portable/MemMang/heap_1.c|Third_Party/FreeRTOS/Source/portable/MemMang/heap_2.c|Third_Party/FreeRTOS/Source/portable/MemMang/heap_3.c|Third_Party/FreeRTOS/Source/portable/MemMang/heap_5.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="startup"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="TS100.fr.ac6.managedbuild.target.gnu.cross.exe.1768512215" name="Executable" projectType="fr.ac6.managedbuild.target.gnu.cross.exe"/>
|
||||
|
||||
@@ -6,19 +6,7 @@
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
|
||||
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="1750838549288477430" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
</extension>
|
||||
</configuration>
|
||||
<configuration id="fr.ac6.managedbuild.config.gnu.cross.exe.release.723264573" name="Release">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
|
||||
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="1750838549288477430" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="-283880394950776525" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
||||
@@ -3467,48 +3467,7 @@ void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c)
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Slave mode selected */
|
||||
else
|
||||
{
|
||||
/* ADDR set --------------------------------------------------------------*/
|
||||
if(((sr1itflags & I2C_FLAG_ADDR) != RESET) && ((itsources & I2C_IT_EVT) != RESET))
|
||||
{
|
||||
I2C_Slave_ADDR(hi2c);
|
||||
}
|
||||
/* STOPF set --------------------------------------------------------------*/
|
||||
else if(((sr1itflags & I2C_FLAG_STOPF) != RESET) && ((itsources & I2C_IT_EVT) != RESET))
|
||||
{
|
||||
I2C_Slave_STOPF(hi2c);
|
||||
}
|
||||
/* I2C in mode Transmitter -----------------------------------------------*/
|
||||
else if((sr2itflags & I2C_FLAG_TRA) != RESET)
|
||||
{
|
||||
/* TXE set and BTF reset -----------------------------------------------*/
|
||||
if(((sr1itflags & I2C_FLAG_TXE) != RESET) && ((itsources & I2C_IT_BUF) != RESET) && ((sr1itflags & I2C_FLAG_BTF) == RESET))
|
||||
{
|
||||
I2C_SlaveTransmit_TXE(hi2c);
|
||||
}
|
||||
/* BTF set -------------------------------------------------------------*/
|
||||
else if(((sr1itflags & I2C_FLAG_BTF) != RESET) && ((itsources & I2C_IT_EVT) != RESET))
|
||||
{
|
||||
I2C_SlaveTransmit_BTF(hi2c);
|
||||
}
|
||||
}
|
||||
/* I2C in mode Receiver --------------------------------------------------*/
|
||||
else
|
||||
{
|
||||
/* RXNE set and BTF reset ----------------------------------------------*/
|
||||
if(((sr1itflags & I2C_FLAG_RXNE) != RESET) && ((itsources & I2C_IT_BUF) != RESET) && ((sr1itflags & I2C_FLAG_BTF) == RESET))
|
||||
{
|
||||
I2C_SlaveReceive_RXNE(hi2c);
|
||||
}
|
||||
/* BTF set -------------------------------------------------------------*/
|
||||
else if(((sr1itflags & I2C_FLAG_BTF) != RESET) && ((itsources & I2C_IT_EVT) != RESET))
|
||||
{
|
||||
I2C_SlaveReceive_BTF(hi2c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4280,7 +4280,7 @@ uint32_t HAL_TIM_ReadCapturedValue(TIM_HandleTypeDef *htim, uint32_t Channel)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Period elapsed callback in non blocking mode
|
||||
* @brief Period elapsed callback in non blocking mode
|
||||
* @param htim : TIM handle
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,7 @@ endif
|
||||
# Discover the source files to build
|
||||
SOURCE := $(shell find . -type f -name '*.c')
|
||||
SOURCE_CPP := $(shell find . -type f -name '*.cpp')
|
||||
SOURCES := $(shell find . -type f -name '*.c*')
|
||||
S_SRCS := $(shell find . -type f -name '*.s')
|
||||
|
||||
APP_INC_DIR = ./inc
|
||||
@@ -31,7 +32,7 @@ HEXFILE_DIR=Hexfile
|
||||
OUTPUT_DIR=Objects
|
||||
|
||||
# code optimisation ------------------------------------------------------------
|
||||
OPTIM=-O2 -finline-small-functions -findirect-inlining -fdiagnostics-color
|
||||
OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# global defines ---------------------------------------------------------------
|
||||
@@ -72,7 +73,7 @@ LINKER_FLAGS=-Wl,--gc-sections \
|
||||
-mcpu=cortex-m3 \
|
||||
-mthumb \
|
||||
-mfloat-abi=soft \
|
||||
-lm
|
||||
-lm -Os -flto -Wl,--undefined=vTaskSwitchContext
|
||||
|
||||
# compiler flags ---------------------------------------------------------------
|
||||
CPUFLAGS=-D GCC_ARMCM3 \
|
||||
@@ -130,7 +131,11 @@ CXXFLAGS=$(CPUFLAGS) \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-fno-non-call-exceptions \
|
||||
-fno-use-cxa-atexit \
|
||||
-fno-use-cxa-atexit \
|
||||
-fno-strict-aliasing \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-fno-threadsafe-statics \
|
||||
-T$(LDSCRIPT)
|
||||
|
||||
|
||||
@@ -172,21 +177,25 @@ OUT_OBJS_CPP=$(addprefix $(OUTPUT_DIR)/,$(OBJS_CPP))
|
||||
OUT_OBJS_S=$(addprefix $(OUTPUT_DIR)/,$(OBJS_S))
|
||||
OUT_HEXFILE=$(addprefix $(HEXFILE_DIR)/,$(OUTPUT_EXE))
|
||||
|
||||
all: $(OUT_HEXFILE).hex
|
||||
|
||||
all: $(OUT_HEXFILE).hex $(OUT_HEXFILE).bin
|
||||
|
||||
#
|
||||
# The rule to create the target directory
|
||||
#
|
||||
|
||||
# Create hexfile
|
||||
%.hex : %.elf
|
||||
$(SIZE) -x $^
|
||||
$(SIZE) $^
|
||||
$(OBJCOPY) $^ -O ihex $@
|
||||
|
||||
%.bin : %.elf
|
||||
$(SIZE) $^
|
||||
$(OBJCOPY) $^ -O binary $@
|
||||
|
||||
$(OUT_HEXFILE).elf : $(OUT_OBJS) $(OUT_OBJS_CPP) $(OUT_OBJS_S) Makefile $(LDSCRIPT)
|
||||
@test -d $(@D) || mkdir -p $(@D)
|
||||
@echo Linking $(OUTPUT_EXE).elf
|
||||
@$(CPP) $(CXXFLAGS) $(OUT_OBJS) $(OUT_OBJS_CPP) $(OUT_OBJS_S) $(LIBS) $(LINKER_FLAGS)
|
||||
@$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) $(LIBS) $(LINKER_FLAGS)
|
||||
|
||||
$(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile
|
||||
@test -d $(@D) || mkdir -p $(@D)
|
||||
|
||||
27
workspace/TS100/TS100.cfg
Normal file
27
workspace/TS100/TS100.cfg
Normal file
@@ -0,0 +1,27 @@
|
||||
# This is an ts100 board with a single STM32F103T8Ux chip
|
||||
#
|
||||
# Generated by System Workbench for STM32
|
||||
# Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s)
|
||||
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
set WORKAREASIZE 0x5000
|
||||
|
||||
transport select "hla_swd"
|
||||
|
||||
set CHIPNAME STM32F103T8Ux
|
||||
|
||||
# Enable debug when in low power modes
|
||||
set ENABLE_LOW_POWER 1
|
||||
|
||||
# Stop Watchdog counters when halt
|
||||
set STOP_WATCHDOG 1
|
||||
|
||||
# STlink Debug clock frequency
|
||||
set CLOCK_FREQ 950
|
||||
|
||||
# use software system reset
|
||||
reset_config none
|
||||
set CONNECT_UNDER_RESET 0
|
||||
|
||||
source [find target/stm32f1x.cfg]
|
||||
@@ -33,5 +33,7 @@ make -j16 lang=BR
|
||||
rm -rf Objects/src
|
||||
make -j16 lang=LT
|
||||
rm -rf Objects/src
|
||||
make -j16 lang=UK
|
||||
make -j16 lang=UA
|
||||
rm -rf Objects/src
|
||||
make -j16 lang=SR
|
||||
rm -rf Objects/src
|
||||
|
||||
39
workspace/TS100/inc/FRToSI2C.hpp
Normal file
39
workspace/TS100/inc/FRToSI2C.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* FRToSI2C.hpp
|
||||
*
|
||||
* Created on: 14Apr.,2018
|
||||
* Author: Ralim
|
||||
*/
|
||||
|
||||
#ifndef FRTOSI2C_HPP_
|
||||
#define FRTOSI2C_HPP_
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
class FRToSI2C {
|
||||
public:
|
||||
|
||||
FRToSI2C(I2C_HandleTypeDef *i2chandle) : i2c(i2chandle),
|
||||
I2CSemaphore(nullptr) {
|
||||
}
|
||||
|
||||
void FRToSInit() {
|
||||
I2CSemaphore = xSemaphoreCreateBinary();
|
||||
xSemaphoreGive(I2CSemaphore);
|
||||
}
|
||||
|
||||
void CpltCallback(); //Normal Tx Callback
|
||||
|
||||
void Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize,
|
||||
uint8_t *pData, uint16_t Size);
|
||||
void Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
|
||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
||||
|
||||
void Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
||||
|
||||
private:
|
||||
I2C_HandleTypeDef *i2c;
|
||||
SemaphoreHandle_t I2CSemaphore;
|
||||
};
|
||||
|
||||
#endif /* FRTOSI2C_HPP_ */
|
||||
@@ -490,7 +490,6 @@ const uint8_t ExtraFontChars[] = {
|
||||
0x00,0xF0,0x08,0xEE,0xE2,0xFA,0xFA,0xE2,0xEE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 10*/
|
||||
|
||||
0x00,0x00,0x38,0xC4,0x00,0x38,0xC4,0x00,0x38,0xC4,0x00,0x00,0x00,0x38,0x3A,0x39,0x38,0x3A,0x39,0x38,0x3A,0x39,0x10,0x10, // heating
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x10,0x10, // cooling
|
||||
0x00,0x60,0xE0,0xFE,0xE0,0xE0,0xE0,0xE0,0xFE,0xE0,0x60,0x00,0x00,0x00,0x00,0x01,0x03,0xFF,0xFF,0x03,0x01,0x00,0x00,0x00, // AC
|
||||
|
||||
0xFC,0x02,0x02,0x02,0x02,0x02,0x02,0x82,0x62,0x1A,0x02,0xFC,0x3F,0x40,0x42,0x46,0x4C,0x58,0x46,0x41,0x40,0x40,0x40,0x3F, // ☑ (check box on, menu true)
|
||||
@@ -603,16 +602,20 @@ const uint8_t SettingsMenuIcons[] = {
|
||||
// Soldering
|
||||
//width = 16
|
||||
//height = 16
|
||||
0x00,0x02,0x04,0x08,0x12,0x24,0xC4,0x42,0x82,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x07,0x0A,0x14,0x28,0x50,0x60,0x00,
|
||||
0x00, 0x02, 0x04, 0x08, 0x12, 0x24, 0xC4, 0x42, 0x82, 0x04,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x02, 0x07, 0x0A, 0x14, 0x28, 0x50,
|
||||
0x60, 0x00,
|
||||
|
||||
|
||||
|
||||
//Sleep
|
||||
//width = 16
|
||||
//height = 16
|
||||
0x00,0xC6,0xE6,0xF6,0xBE,0x9E,0x8E,0x86,0x00,0x00,0x40,0x40,0xC0,0xC0,0xC0,0x00,
|
||||
0x00,0x01,0x01,0x01,0x45,0x65,0x75,0x5D,0x4C,0x00,0x06,0x07,0x07,0x05,0x04,0x00,
|
||||
0x00, 0xC6, 0xE6, 0xF6, 0xBE, 0x9E, 0x8E, 0x86, 0x00, 0x00,
|
||||
0x40, 0x40, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x01, 0x01, 0x01,
|
||||
0x45, 0x65, 0x75, 0x5D, 0x4C, 0x00, 0x06, 0x07, 0x07, 0x05,
|
||||
0x04, 0x00,
|
||||
|
||||
|
||||
|
||||
@@ -625,14 +628,18 @@ const uint8_t SettingsMenuIcons[] = {
|
||||
//Wrench
|
||||
///width = 16
|
||||
//height = 16
|
||||
0x00,0x18,0x30,0x32,0x7E,0x7C,0xF0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x0F,0x3E,0x7E,0x4C,0x0C,0x18,0x00,
|
||||
0x00, 0x18, 0x30, 0x32, 0x7E, 0x7C, 0xF0, 0xC0, 0x80, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x03, 0x0F, 0x3E, 0x7E, 0x4C, 0x0C,
|
||||
0x18, 0x00,
|
||||
#ifdef NOTUSED
|
||||
//Calibration (Not used, kept for future menu layouts)
|
||||
//width = 16
|
||||
//height = 16
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE8,0x70,0x7A,0x5E,0x8E,0x1C,0x30,0x00,
|
||||
0x00,0x10,0x38,0x1C,0x0E,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE8, 0x70,
|
||||
0x7A, 0x5E, 0x8E, 0x1C, 0x30, 0x00, 0x00, 0x10, 0x38, 0x1C,
|
||||
0x0E, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -101,12 +101,14 @@
|
||||
#define configTICK_RATE_HZ ((TickType_t)100)
|
||||
#define configMAX_PRIORITIES ( 4 )
|
||||
#define configMINIMAL_STACK_SIZE ((uint16_t)256)
|
||||
#define configTOTAL_HEAP_SIZE ((size_t)10240)
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
#define configTOTAL_HEAP_SIZE ((size_t)10240) /*Currently use about 9000*/
|
||||
#define configMAX_TASK_NAME_LEN ( 48 )
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 8
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||
|
||||
|
||||
/* Co-routine definitions. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
@@ -122,6 +124,7 @@ to exclude the API function. */
|
||||
#define INCLUDE_vTaskDelayUntil 0
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
|
||||
/* Cortex-M specific definitions. */
|
||||
#ifdef __NVIC_PRIO_BITS
|
||||
|
||||
@@ -8,20 +8,21 @@
|
||||
#ifndef LIS2DH12_HPP_
|
||||
#define LIS2DH12_HPP_
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "FRToSI2C.hpp"
|
||||
#include "LIS2DH12_defines.hpp"
|
||||
#include "hardware.h"
|
||||
|
||||
class LIS2DH12 {
|
||||
public:
|
||||
LIS2DH12(I2C_HandleTypeDef* i2cHandle);
|
||||
LIS2DH12(FRToSI2C* i2cHandle) : i2c(i2cHandle) {}
|
||||
void initalize();
|
||||
uint8_t getOrientation();
|
||||
Orientation getOrientation() { return static_cast<Orientation>((I2C_RegisterRead(LIS_INT2_SRC) >> 2) - 1); }
|
||||
void getAxisReadings(int16_t *x, int16_t *y, int16_t *z);
|
||||
|
||||
private:
|
||||
void setSensitivity(uint8_t threshold, uint8_t filterTime); // Sets the sensitivity of the unit
|
||||
|
||||
void I2C_RegisterWrite(uint8_t reg, uint8_t data);
|
||||
uint8_t I2C_RegisterRead(uint8_t reg);
|
||||
I2C_HandleTypeDef* i2c;
|
||||
FRToSI2C* i2c;
|
||||
};
|
||||
|
||||
#endif /* LIS2DH12_HPP_ */
|
||||
|
||||
@@ -9,21 +9,23 @@
|
||||
#define MMA8652FC_HPP_
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "MMA8652FC_defines.h"
|
||||
#include "FRToSI2C.hpp"
|
||||
#include "hardware.h"
|
||||
|
||||
class MMA8652FC {
|
||||
|
||||
public:
|
||||
|
||||
MMA8652FC(I2C_HandleTypeDef* i2cHandle);
|
||||
MMA8652FC(FRToSI2C* i2cHandle) : i2c(i2cHandle) {}
|
||||
void initalize(); // Initalize the system
|
||||
uint8_t getOrientation();// Reads the I2C register and returns the orientation (true == left)
|
||||
Orientation getOrientation();// Reads the I2C register and returns the orientation (true == left)
|
||||
void getAxisReadings(int16_t *x, int16_t *y, int16_t *z);
|
||||
|
||||
private:
|
||||
void setSensitivity(uint8_t threshold, uint8_t filterTime); // Sets the sensitivity of the unit
|
||||
|
||||
void I2C_RegisterWrite(uint8_t reg, uint8_t data);
|
||||
uint8_t I2C_RegisterRead(uint8_t reg);
|
||||
I2C_HandleTypeDef* i2c;
|
||||
FRToSI2C* i2c;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <hardware.h>
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "FRToSI2C.hpp"
|
||||
#include "Font.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -20,39 +22,75 @@ extern "C" {
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#define DEVICEADDR_OLED (0x3c<<1)
|
||||
#define OLED_WIDTH 96
|
||||
#define DEVICEADDR_OLED (0x3c<<1)
|
||||
#define OLED_WIDTH 96
|
||||
#define FRAMEBUFFER_START 17
|
||||
|
||||
|
||||
class OLED {
|
||||
public:
|
||||
OLED(I2C_HandleTypeDef* i2cHandle); // Initialize Driver and store I2C pointer
|
||||
OLED(FRToSI2C* i2cHandle); // Initialize Driver and store I2C pointer
|
||||
void initialize(); // Startup the I2C coms (brings screen out of reset etc)
|
||||
void refresh(); // Draw the buffer out to the LCD using the DMA Channel
|
||||
void drawChar(char c, char preCursorCommand = '\0');// Draw a character to a specific location
|
||||
void displayOnOff(bool on); // Turn the screen on or not
|
||||
|
||||
// Draw the buffer out to the LCD using the DMA Channel
|
||||
void refresh() {
|
||||
i2c->Transmit( DEVICEADDR_OLED, screenBuffer, FRAMEBUFFER_START + (OLED_WIDTH * 2));
|
||||
//DMA tx time is ~ 20mS Ensure after calling this you delay for at least 25ms
|
||||
//or we need to goto double buffering
|
||||
}
|
||||
|
||||
void drawChar(char c, char preCursorCommand = '\0'); // Draw a character to a specific location
|
||||
// Turn the screen on or not
|
||||
void displayOnOff(bool on) {
|
||||
displayOnOffState = on;
|
||||
screenBuffer[1] = on ? 0xAF : 0xAE;
|
||||
}
|
||||
void setRotation(bool leftHanded); // Set the rotation for the screen
|
||||
bool getRotation(); // Get the current rotation of the LCD
|
||||
// Get the current rotation of the LCD
|
||||
bool getRotation() const {
|
||||
return inLeftHandedMode;
|
||||
}
|
||||
void print(const char* string); // Draw a string to the current location, with current font
|
||||
void setCursor(int16_t x, int16_t y); // Set the cursor location by pixels
|
||||
void setCharCursor(int16_t x, int16_t y); //Set cursor location by chars in current font
|
||||
void setFont(uint8_t fontNumber);// (Future) Set the font that is being used
|
||||
void drawImage(const uint8_t* buffer, uint8_t x, uint8_t width);
|
||||
// Set the cursor location by pixels
|
||||
void setCursor(int16_t x, int16_t y) {
|
||||
cursor_x = x;
|
||||
cursor_y = y;
|
||||
}
|
||||
//Set cursor location by chars in current font
|
||||
void setCharCursor(int16_t x, int16_t y) {
|
||||
cursor_x = x * fontWidth;
|
||||
cursor_y = y * fontHeight;
|
||||
}
|
||||
void setFont(uint8_t fontNumber); // (Future) Set the font that is being used
|
||||
void drawImage(const uint8_t* buffer, uint8_t x, uint8_t width) {
|
||||
drawArea(x, 0, width, 16, buffer);
|
||||
}
|
||||
// Draws an image to the buffer, at x offset from top to bottom (fixed height renders)
|
||||
void printNumber(uint16_t number, uint8_t places);
|
||||
// Draws a number at the current cursor location
|
||||
void clearScreen(); // Clears the buffer
|
||||
void drawBattery(uint8_t state); // Draws the battery level symbol
|
||||
void drawCheckbox(bool state); // Draws a checkbox
|
||||
// Clears the buffer
|
||||
void clearScreen() {
|
||||
memset(&screenBuffer[FRAMEBUFFER_START], 0, OLED_WIDTH * 2);
|
||||
}
|
||||
// Draws the battery level symbol
|
||||
void drawBattery(uint8_t state) {
|
||||
drawSymbol(3 + (state > 10 ? 10 : state));
|
||||
}
|
||||
// Draws a checkbox
|
||||
void drawCheckbox(bool state) {
|
||||
drawSymbol((state) ? 16 : 17);
|
||||
}
|
||||
void drawSymbol(uint8_t symbolID);//Used for drawing symbols of a predictable width
|
||||
void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
||||
const uint8_t* ptr);
|
||||
void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t* ptr); //Draw an area, but y must be aligned on 0/8 offset
|
||||
void fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t value); //Fill an area, but y must be aligned on 0/8 offset
|
||||
void drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,bool clear);
|
||||
void drawHeatSymbol(uint8_t state);
|
||||
private:
|
||||
|
||||
//Draw a buffer to the screen buffer
|
||||
|
||||
I2C_HandleTypeDef* i2c; //i2c Pointer
|
||||
FRToSI2C* i2c; //i2c Pointer
|
||||
const uint8_t* currentFont; // Pointer to the current font used for rendering to the buffer
|
||||
uint8_t screenBuffer[12 + 96 + 96 + 10]; // The data buffer
|
||||
uint8_t* firstStripPtr; // Pointers to the strips to allow for buffer having extra content
|
||||
uint8_t* secondStripPtr; //Pointers to the strips
|
||||
bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
|
||||
@@ -60,6 +98,7 @@ private:
|
||||
uint8_t fontWidth, fontHeight;
|
||||
int16_t cursor_x, cursor_y;
|
||||
uint8_t displayOffset;
|
||||
uint8_t screenBuffer[16 + (OLED_WIDTH * 2) + 10]; // The data buffer
|
||||
};
|
||||
|
||||
#endif /* OLED_HPP_ */
|
||||
|
||||
@@ -11,31 +11,34 @@
|
||||
#define SETTINGS_H_
|
||||
#include <stdint.h>
|
||||
#include "stm32f1xx_hal.h"
|
||||
#define SETTINGSVERSION 0x13 /*Change this if you change the struct below to prevent people getting out of sync*/
|
||||
#define SETTINGSVERSION 0x14 /*Change this if you change the struct below to prevent people getting out of sync*/
|
||||
|
||||
/*
|
||||
* This struct must be a multiple of 2 bytes as it is saved / restored from flash in uint16_t chunks
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t SolderingTemp; //current set point for the iron
|
||||
uint16_t SleepTemp; //temp to drop to in sleep
|
||||
uint8_t SleepTime; //minutes timeout to sleep
|
||||
uint8_t cutoutSetting; // The voltage we cut out at for under voltage
|
||||
uint8_t OrientationMode:2; //If true we want to invert the display for lefties
|
||||
uint8_t sensitivity :4; //Sensitivity of accelerometer (5 bits)
|
||||
uint8_t autoStartMode :2; //Should the unit automatically jump straight into soldering mode when power is applied
|
||||
uint8_t ShutdownTime; //Time until unit shuts down if left alone
|
||||
uint8_t boostModeEnabled :1; //Boost mode swaps BUT_A in soldering mode to temporary soldering temp over-ride
|
||||
uint8_t coolingTempBlink :1; //Should the temperature blink on the cool down screen until its <50C
|
||||
uint16_t SolderingTemp; //current set point for the iron
|
||||
uint16_t SleepTemp; //temp to drop to in sleep
|
||||
uint8_t SleepTime; //minutes timeout to sleep
|
||||
uint8_t cutoutSetting; // The voltage we cut out at for under voltage
|
||||
uint8_t OrientationMode:2; //If true we want to invert the display for lefties
|
||||
uint8_t sensitivity :4; //Sensitivity of accelerometer (5 bits)
|
||||
uint8_t autoStartMode :2; //Should the unit automatically jump straight into soldering mode when power is applied
|
||||
uint8_t ShutdownTime; //Time until unit shuts down if left alone
|
||||
uint8_t boostModeEnabled :1; //Boost mode swaps BUT_A in soldering mode to temporary soldering temp over-ride
|
||||
uint8_t coolingTempBlink :1; //Should the temperature blink on the cool down screen until its <50C
|
||||
uint8_t detailedIDLE :1; //Detailed idle screen
|
||||
uint8_t detailedSoldering :1; //Detailed soldering screens
|
||||
uint8_t temperatureInF; //Should the temp be in F or C (true is F)
|
||||
uint8_t descriptionScrollSpeed:1; // Description scroll speed
|
||||
uint16_t voltageDiv; //Voltage divisor factor
|
||||
uint16_t BoostTemp; //Boost mode set point for the iron
|
||||
int16_t CalibrationOffset; //This stores the temperature offset for this tip in the iron.
|
||||
uint8_t version; //Used to track if a reset is needed on firmware upgrade
|
||||
uint32_t padding; //This is here for in case we are not an even divisor so that nothing gets cut off
|
||||
uint8_t temperatureInF; //Should the temp be in F or C (true is F)
|
||||
uint8_t descriptionScrollSpeed:1; // Description scroll speed
|
||||
uint16_t voltageDiv; //Voltage divisor factor
|
||||
uint16_t BoostTemp; //Boost mode set point for the iron
|
||||
int16_t CalibrationOffset; //This stores the temperature offset for this tip in the iron.
|
||||
uint8_t PID_P; //PID P Term
|
||||
uint8_t PID_I; //PID I Term
|
||||
uint8_t PID_D; //PID D Term
|
||||
uint8_t version; //Used to track if a reset is needed on firmware upgrade
|
||||
uint32_t padding; //This is here for in case we are not an even divisor so that nothing gets cut off
|
||||
} systemSettingsType;
|
||||
|
||||
extern volatile systemSettingsType systemSettings;
|
||||
|
||||
@@ -17,9 +17,10 @@ extern "C" {
|
||||
extern ADC_HandleTypeDef hadc1;
|
||||
extern DMA_HandleTypeDef hdma_adc1;
|
||||
|
||||
extern DMA_HandleTypeDef hdma_i2c1_rx;
|
||||
extern DMA_HandleTypeDef hdma_i2c1_tx;
|
||||
extern I2C_HandleTypeDef hi2c1;
|
||||
|
||||
|
||||
extern IWDG_HandleTypeDef hiwdg;
|
||||
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum Orientation {
|
||||
ORIENTATION_LEFT_HAND = 0,
|
||||
ORIENTATION_RIGHT_HAND = 1,
|
||||
ORIENTATION_FLAT = 3
|
||||
};
|
||||
|
||||
#define KEY_B_Pin GPIO_PIN_6
|
||||
#define KEY_B_GPIO_Port GPIOA
|
||||
#define TMP36_INPUT_Pin GPIO_PIN_7
|
||||
|
||||
@@ -25,5 +25,20 @@ enum ButtonState {
|
||||
|
||||
ButtonState getButtonState();
|
||||
void waitForButtonPressOrTimeout(uint32_t timeout);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc);
|
||||
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __MAIN_H */
|
||||
|
||||
88
workspace/TS100/src/FRToSI2C.cpp
Normal file
88
workspace/TS100/src/FRToSI2C.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* FRToSI2C.cpp
|
||||
*
|
||||
* Created on: 14Apr.,2018
|
||||
* Author: Ralim
|
||||
*/
|
||||
|
||||
#include "FRToSI2C.hpp"
|
||||
|
||||
void FRToSI2C::CpltCallback() {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
i2c->State = HAL_I2C_STATE_READY;//Force state reset
|
||||
if (I2CSemaphore) {
|
||||
xSemaphoreGiveFromISR(I2CSemaphore, &xHigherPriorityTaskWoken);
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
}
|
||||
|
||||
void FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
|
||||
uint16_t MemAddSize, uint8_t* pData, uint16_t Size) {
|
||||
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED
|
||||
|| I2CSemaphore == NULL) {
|
||||
//no RToS, run blocking code
|
||||
HAL_I2C_Mem_Read(i2c, DevAddress, MemAddress, MemAddSize, pData, Size,
|
||||
5000);
|
||||
} else {
|
||||
//RToS is active, run threading
|
||||
//Get the mutex so we can use the I2C port
|
||||
//Wait up to 1 second for the mutex
|
||||
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 5000 ) == pdTRUE) {
|
||||
if (HAL_I2C_Mem_Read(i2c, DevAddress, MemAddress, MemAddSize, pData,
|
||||
Size, 5000) != HAL_OK) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
xSemaphoreGive(I2CSemaphore);
|
||||
} else {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
|
||||
uint16_t MemAddSize, uint8_t* pData, uint16_t Size) {
|
||||
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED
|
||||
|| I2CSemaphore == NULL) {
|
||||
//no RToS, run blocking code
|
||||
HAL_I2C_Mem_Write(i2c, DevAddress, MemAddress, MemAddSize, pData, Size,
|
||||
5000);
|
||||
} else {
|
||||
//RToS is active, run threading
|
||||
//Get the mutex so we can use the I2C port
|
||||
//Wait up to 1 second for the mutex
|
||||
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 5000 ) == pdTRUE) {
|
||||
if (HAL_I2C_Mem_Write(i2c, DevAddress, MemAddress, MemAddSize,
|
||||
pData, Size, 5000) != HAL_OK) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
xSemaphoreGive(I2CSemaphore);
|
||||
|
||||
} else {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t* pData, uint16_t Size) {
|
||||
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED
|
||||
|| I2CSemaphore == NULL) {
|
||||
//no RToS, run blocking code
|
||||
HAL_I2C_Master_Transmit(i2c, DevAddress, pData, Size, 5000);
|
||||
} else {
|
||||
//RToS is active, run threading
|
||||
//Get the mutex so we can use the I2C port
|
||||
//Wait up to 1 second for the mutex
|
||||
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 5000 ) == pdTRUE) {
|
||||
if (HAL_I2C_Master_Transmit_DMA(i2c, DevAddress, pData, Size)
|
||||
!= HAL_OK) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
//xSemaphoreGive(I2CSemaphore);
|
||||
} else {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,67 +7,51 @@
|
||||
|
||||
#include <LIS2DH12.hpp>
|
||||
#include "cmsis_os.h"
|
||||
LIS2DH12::LIS2DH12(I2C_HandleTypeDef* i2cHandle) {
|
||||
i2c = i2cHandle;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const uint8_t reg;
|
||||
const uint8_t value;
|
||||
} LIS_REG;
|
||||
|
||||
static const LIS_REG i2c_registers[] = {
|
||||
{LIS_CTRL_REG1, 0x17}, // 25Hz
|
||||
{LIS_CTRL_REG2, 0b00001000}, // Highpass filter off
|
||||
{LIS_CTRL_REG3, 0b01100000}, // Setup interrupt pins
|
||||
{LIS_CTRL_REG4, 0b00001000}, // Block update mode off, HR on
|
||||
{LIS_CTRL_REG5, 0b00000010},
|
||||
{LIS_CTRL_REG6, 0b01100010},
|
||||
//Basically setup the unit to run, and enable 4D orientation detection
|
||||
{LIS_INT2_CFG, 0b01111110}, //setup for movement detection
|
||||
{LIS_INT2_THS, 0x28},
|
||||
{LIS_INT2_DURATION, 64},
|
||||
{LIS_INT1_CFG, 0b01111110},
|
||||
{LIS_INT1_THS, 0x28},
|
||||
{LIS_INT1_DURATION, 64}
|
||||
};
|
||||
|
||||
void LIS2DH12::initalize() {
|
||||
I2C_RegisterWrite(LIS_CTRL_REG1, 0x17); //25Hz
|
||||
I2C_RegisterWrite(LIS_CTRL_REG2, 0b00001000); //Highpass filter off
|
||||
I2C_RegisterWrite(LIS_CTRL_REG3, 0b01100000); //Setup interrupt pins
|
||||
I2C_RegisterWrite(LIS_CTRL_REG4, 0b00001000); //Block update mode off,HR on
|
||||
I2C_RegisterWrite(LIS_CTRL_REG5, 0b00000010);
|
||||
I2C_RegisterWrite(LIS_CTRL_REG6, 0b01100010);
|
||||
|
||||
//Basically setup the unit to run, and enable 4D orientation detection
|
||||
I2C_RegisterWrite(LIS_INT2_CFG, 0b01111110); //setup for movement detection
|
||||
I2C_RegisterWrite(LIS_INT2_THS, 0x28);
|
||||
I2C_RegisterWrite(LIS_INT2_DURATION, 64);
|
||||
I2C_RegisterWrite(LIS_INT1_CFG, 0b01111110); //setup for movement detection
|
||||
I2C_RegisterWrite(LIS_INT1_THS, 0x28);
|
||||
I2C_RegisterWrite(LIS_INT1_DURATION, 64);
|
||||
|
||||
}
|
||||
|
||||
//0=no change, 1= right handed, 2= left handed
|
||||
uint8_t LIS2DH12::getOrientation() {
|
||||
// 8=right handed,4=left,16=flat
|
||||
//So we ignore if not 8/4
|
||||
taskENTER_CRITICAL();
|
||||
uint8_t pos = I2C_RegisterRead(LIS_INT2_SRC);
|
||||
taskEXIT_CRITICAL();
|
||||
if (pos == 8)
|
||||
return 1;
|
||||
else if (pos == 4)
|
||||
return 2;
|
||||
else
|
||||
return 0;
|
||||
for (size_t index = 0; index < (sizeof(i2c_registers) / sizeof(i2c_registers[0])); index++) {
|
||||
I2C_RegisterWrite(i2c_registers[index].reg, i2c_registers[index].value);
|
||||
}
|
||||
}
|
||||
|
||||
void LIS2DH12::getAxisReadings(int16_t* x, int16_t* y, int16_t* z) {
|
||||
uint8_t tempArr[6];
|
||||
taskENTER_CRITICAL();
|
||||
while (HAL_I2C_Mem_Read(i2c, LIS2DH_I2C_ADDRESS, 0xA8,
|
||||
I2C_MEMADD_SIZE_8BIT, (uint8_t*) tempArr, 6, 5000) != HAL_OK) {
|
||||
HAL_Delay(5);
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
i2c->Mem_Read(LIS2DH_I2C_ADDRESS, 0xA8, I2C_MEMADD_SIZE_8BIT,
|
||||
(uint8_t*) tempArr, 6);
|
||||
|
||||
(*x) = ((uint16_t) (tempArr[1] << 8 | tempArr[0]));
|
||||
(*y) = ((uint16_t) (tempArr[3] << 8 | tempArr[2]));
|
||||
(*z) = ((uint16_t) (tempArr[5] << 8 | tempArr[4]));
|
||||
}
|
||||
|
||||
void LIS2DH12::setSensitivity(uint8_t threshold, uint8_t filterTime) {
|
||||
}
|
||||
|
||||
void LIS2DH12::I2C_RegisterWrite(uint8_t reg, uint8_t data) {
|
||||
HAL_I2C_Mem_Write(i2c, LIS2DH_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT, &data,
|
||||
1, 500);
|
||||
i2c->Mem_Write(LIS2DH_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT, &data, 1);
|
||||
|
||||
}
|
||||
|
||||
uint8_t LIS2DH12::I2C_RegisterRead(uint8_t reg) {
|
||||
uint8_t tx_data[1];
|
||||
HAL_I2C_Mem_Read(i2c, LIS2DH_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT,
|
||||
tx_data, 1, 500);
|
||||
i2c->Mem_Read( LIS2DH_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT, tx_data, 1);
|
||||
return tx_data[0];
|
||||
}
|
||||
|
||||
@@ -8,79 +8,72 @@
|
||||
#include <MMA8652FC.hpp>
|
||||
#include "cmsis_os.h"
|
||||
|
||||
MMA8652FC::MMA8652FC(I2C_HandleTypeDef* i2cHandle) {
|
||||
i2c = i2cHandle;
|
||||
}
|
||||
typedef struct {
|
||||
const uint8_t reg;
|
||||
const uint8_t val;
|
||||
} MMA_REG;
|
||||
|
||||
static const MMA_REG i2c_registers[] = {
|
||||
{CTRL_REG2, 0}, //Normal mode
|
||||
{CTRL_REG2, 0x40}, // Reset all registers to POR values
|
||||
{FF_MT_CFG_REG, 0x78}, // Enable motion detection for X, Y, Z axis, latch disabled
|
||||
{PL_CFG_REG, 0x40}, //Enable the orientation detection
|
||||
{PL_COUNT_REG, 200}, //200 count debounce
|
||||
{PL_BF_ZCOMP_REG, 0b01000111}, //Set the threshold to 42 degrees
|
||||
{P_L_THS_REG, 0b10011100}, //Up the trip angles
|
||||
{CTRL_REG4, 0x01 | (1 << 4)}, // Enable dataready interrupt & orientation interrupt
|
||||
{CTRL_REG5, 0x01}, // Route data ready interrupts to INT1 ->PB5 ->EXTI5, leaving orientation routed to INT2
|
||||
{CTRL_REG2, 0x12}, //Set maximum resolution oversampling
|
||||
{XYZ_DATA_CFG_REG, (1 << 4)}, //select high pass filtered data
|
||||
{HP_FILTER_CUTOFF_REG, 0x03}, //select high pass filtered data
|
||||
{CTRL_REG1, 0x19} // ODR=12 Hz, Active mode
|
||||
};
|
||||
|
||||
void MMA8652FC::I2C_RegisterWrite(uint8_t reg, uint8_t data) {
|
||||
|
||||
HAL_I2C_Mem_Write(i2c, MMA8652FC_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT,
|
||||
&data, 1, 500);
|
||||
i2c->Mem_Write( MMA8652FC_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT, &data, 1);
|
||||
}
|
||||
|
||||
uint8_t MMA8652FC::I2C_RegisterRead(uint8_t reg) {
|
||||
uint8_t tx_data[1];
|
||||
HAL_I2C_Mem_Read(i2c, MMA8652FC_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT,
|
||||
tx_data, 1, 500);
|
||||
i2c->Mem_Read( MMA8652FC_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT, tx_data,
|
||||
1);
|
||||
|
||||
return tx_data[0];
|
||||
}
|
||||
void MMA8652FC::initalize() {
|
||||
size_t index = 0;
|
||||
|
||||
//send all the init commands to the unit
|
||||
I2C_RegisterWrite(CTRL_REG2, 0); //Normal mode
|
||||
I2C_RegisterWrite( CTRL_REG2, 0x40); // Reset all registers to POR values
|
||||
HAL_Delay(2); // ~1ms delay
|
||||
I2C_RegisterWrite(FF_MT_CFG_REG, 0x78); // Enable motion detection for X, Y, Z axis, latch disabled
|
||||
|
||||
I2C_RegisterWrite(PL_CFG_REG, 0x40); //Enable the orientation detection
|
||||
I2C_RegisterWrite(PL_COUNT_REG, 200); //200 count debounce
|
||||
I2C_RegisterWrite(PL_BF_ZCOMP_REG, 0b01000111); //Set the threshold to 42 degrees
|
||||
I2C_RegisterWrite(P_L_THS_REG, 0b10011100); //Up the trip angles
|
||||
I2C_RegisterWrite( CTRL_REG4, 0x01 | (1 << 4)); // Enable dataready interrupt & orientation interrupt
|
||||
I2C_RegisterWrite( CTRL_REG5, 0x01); // Route data ready interrupts to INT1 ->PB5 ->EXTI5, leaving orientation routed to INT2
|
||||
I2C_RegisterWrite( CTRL_REG2, 0x12); //Set maximum resolution oversampling
|
||||
I2C_RegisterWrite( XYZ_DATA_CFG_REG, (1 << 4)); //select high pass filtered data
|
||||
I2C_RegisterWrite( HP_FILTER_CUTOFF_REG, 0x03); //select high pass filtered data
|
||||
I2C_RegisterWrite(i2c_registers[index].reg, i2c_registers[index].val); index++;
|
||||
I2C_RegisterWrite(i2c_registers[index].reg, i2c_registers[index].val); index++;
|
||||
|
||||
I2C_RegisterWrite( CTRL_REG1, 0x19); // ODR=12 Hz, Active mode
|
||||
HAL_Delay(2); // ~1ms delay
|
||||
|
||||
while (index < (sizeof(i2c_registers) / sizeof(i2c_registers[0]))) {
|
||||
I2C_RegisterWrite(i2c_registers[index].reg, i2c_registers[index].val); index++;
|
||||
}
|
||||
}
|
||||
|
||||
void MMA8652FC::setSensitivity(uint8_t threshold, uint8_t filterTime) {
|
||||
uint8_t sens = 9 * 2 + 17;
|
||||
sens -= 2 * threshold;
|
||||
taskENTER_CRITICAL();
|
||||
I2C_RegisterWrite( CTRL_REG1, 0); // sleep mode
|
||||
I2C_RegisterWrite(FF_MT_THS_REG, (sens & 0x7F));// Set accumulation threshold
|
||||
I2C_RegisterWrite(FF_MT_COUNT_REG, filterTime); // Set debounce threshold
|
||||
I2C_RegisterWrite( CTRL_REG1, 0x31); // ODR=12 Hz, Active mode
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
uint8_t MMA8652FC::getOrientation() {
|
||||
Orientation MMA8652FC::getOrientation() {
|
||||
//First read the PL_STATUS register
|
||||
taskENTER_CRITICAL();
|
||||
uint8_t plStatus = I2C_RegisterRead(PL_STATUS_REG);
|
||||
taskEXIT_CRITICAL();
|
||||
if ((plStatus & 0b10000000) == 0b10000000) {
|
||||
plStatus >>= 1; //We don't need the up/down bit
|
||||
plStatus &= 0x03; //mask to the two lower bits
|
||||
|
||||
//0 == left handed
|
||||
//1 == right handed
|
||||
|
||||
return plStatus==0?2:1;
|
||||
} else
|
||||
return 0;
|
||||
return static_cast<Orientation>(plStatus);
|
||||
}
|
||||
|
||||
return ORIENTATION_FLAT;
|
||||
}
|
||||
void MMA8652FC::getAxisReadings(int16_t *x, int16_t *y, int16_t *z) {
|
||||
uint8_t tempArr[6];
|
||||
taskENTER_CRITICAL();
|
||||
while (HAL_I2C_Mem_Read(i2c, MMA8652FC_I2C_ADDRESS, OUT_X_MSB_REG,
|
||||
I2C_MEMADD_SIZE_8BIT, (uint8_t*) tempArr, 6, 0xFFFF) != HAL_OK) {
|
||||
HAL_Delay(5);
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
i2c->Mem_Read( MMA8652FC_I2C_ADDRESS, OUT_X_MSB_REG,I2C_MEMADD_SIZE_8BIT, (uint8_t*) tempArr, 6);
|
||||
|
||||
(*x) = tempArr[0] << 8 | tempArr[1];
|
||||
(*y) = tempArr[2] << 8 | tempArr[3];
|
||||
(*z) = tempArr[4] << 8 | tempArr[5];
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
/*http://www.displayfuture.com/Display/datasheet/controller/SSD1307.pdf*/
|
||||
/*All commands are prefixed with 0x80*/
|
||||
/*Data packets are prefixed with 0x40*/
|
||||
const uint8_t configLength = 50;
|
||||
uint8_t OLED_Setup_Array[] = { /**/
|
||||
0x80, 0xAE,/*Display off*/
|
||||
0x80, 0xD5,/*Set display clock divide ratio / osc freq*/
|
||||
@@ -43,56 +42,40 @@ uint8_t OLED_Setup_Array[] = { /**/
|
||||
};
|
||||
//Setup based on the SSD1307 and modified for the SSD1306
|
||||
|
||||
OLED::OLED(I2C_HandleTypeDef* i2cHandle) {
|
||||
const uint8_t REFRESH_COMMANDS[17] = {
|
||||
0x80, 0xAF,
|
||||
0x80, 0x21,
|
||||
0x80, 0x20,
|
||||
0x80, 0x7F,
|
||||
0x80, 0xC0,
|
||||
0x80, 0x22,
|
||||
0x80, 0x00,
|
||||
0x80, 0x01,
|
||||
0x40
|
||||
};
|
||||
|
||||
OLED::OLED(FRToSI2C* i2cHandle) {
|
||||
i2c = i2cHandle;
|
||||
cursor_x = cursor_y = 0;
|
||||
currentFont = FONT_12;
|
||||
fontWidth = 12;
|
||||
inLeftHandedMode = false;
|
||||
firstStripPtr = &screenBuffer[13];
|
||||
secondStripPtr = &screenBuffer[13 + 96];
|
||||
firstStripPtr = &screenBuffer[FRAMEBUFFER_START];
|
||||
secondStripPtr = &screenBuffer[FRAMEBUFFER_START + OLED_WIDTH];
|
||||
fontHeight = 16;
|
||||
fontWidth = 12;
|
||||
displayOffset = 0;
|
||||
displayOnOffState = true;
|
||||
|
||||
}
|
||||
|
||||
void OLED::initialize() {
|
||||
memcpy(&screenBuffer[0], &REFRESH_COMMANDS[0], sizeof(REFRESH_COMMANDS));
|
||||
|
||||
HAL_Delay(5);
|
||||
HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(5);
|
||||
HAL_Delay(10);
|
||||
//Send the setup settings
|
||||
HAL_I2C_Master_Transmit(i2c, DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array,
|
||||
configLength, 0xFFFF);
|
||||
//displayOnOff(true);
|
||||
|
||||
}
|
||||
|
||||
//Write out the buffer to the OLEd & call any rendering objects
|
||||
void OLED::refresh() {
|
||||
screenBuffer[0] = 0x80;
|
||||
screenBuffer[1] = 0x21;
|
||||
screenBuffer[2] = 0x80;
|
||||
screenBuffer[3] = inLeftHandedMode ? 0 : 32; //display is shifted by 32 in left handed mode as driver ram is 128 wide
|
||||
screenBuffer[4] = 0x80;
|
||||
screenBuffer[5] = inLeftHandedMode ? 95 : 0x7F; //End address of the ram segment we are writing to (96 wide)
|
||||
|
||||
screenBuffer[6] = 0x80; //Set pages to rollover after 2
|
||||
screenBuffer[7] = 0x22;
|
||||
screenBuffer[8] = 0x80;
|
||||
screenBuffer[9] = 0x00; //start page 0
|
||||
screenBuffer[10] = 0x80;
|
||||
screenBuffer[11] = 0x01;
|
||||
|
||||
screenBuffer[12] = 0x40; //start of data marker
|
||||
taskENTER_CRITICAL();
|
||||
//Because I2C is shared, we cant task switch in the middle of the xfer
|
||||
|
||||
HAL_I2C_Master_Transmit(i2c, DEVICEADDR_OLED, screenBuffer, 12 + 96 * 2 + 1,
|
||||
500);
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array, sizeof(OLED_Setup_Array));
|
||||
displayOnOff(true);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -101,10 +84,9 @@ void OLED::refresh() {
|
||||
* Precursor is the command char that is used to select the table.
|
||||
*/
|
||||
void OLED::drawChar(char c, char PrecursorCommand) {
|
||||
if( c=='\n' && cursor_y==0)
|
||||
{
|
||||
cursor_x=0;
|
||||
cursor_y=8;
|
||||
if (c == '\n' && cursor_y == 0) {
|
||||
cursor_x = 0;
|
||||
cursor_y = 8;
|
||||
}
|
||||
if (c < ' ') {
|
||||
return;
|
||||
@@ -128,10 +110,10 @@ void OLED::drawChar(char c, char PrecursorCommand) {
|
||||
index = (128) + (c);
|
||||
break;
|
||||
#if defined(LANG_RU) || defined(LANG_UK) || defined(LANG_SR) || defined(LANG_BG) || defined(LANG_MK)
|
||||
case 0xD0:
|
||||
case 0xD0:
|
||||
index = (192) + (c);
|
||||
break;
|
||||
case 0xD1:
|
||||
case 0xD1:
|
||||
index = (256) + (c);
|
||||
break;
|
||||
#else
|
||||
@@ -156,40 +138,26 @@ void OLED::drawChar(char c, char PrecursorCommand) {
|
||||
cursor_x += fontWidth;
|
||||
}
|
||||
|
||||
void OLED::displayOnOff(bool on) {
|
||||
|
||||
if (on != displayOnOffState) {
|
||||
uint8_t data[6] = { 0x80, 0X8D, 0x80, 0X14, 0x80, 0XAF }; //on
|
||||
if (!on) {
|
||||
data[3] = 0x10;
|
||||
data[5] = 0xAE;
|
||||
}
|
||||
taskENTER_CRITICAL();
|
||||
|
||||
HAL_I2C_Master_Transmit(i2c, DEVICEADDR_OLED, data, 6, 0xFFFF);
|
||||
taskEXIT_CRITICAL();
|
||||
displayOnOffState = on;
|
||||
}
|
||||
}
|
||||
|
||||
void OLED::setRotation(bool leftHanded) {
|
||||
if (inLeftHandedMode != leftHanded) {
|
||||
//send command struct again with changes
|
||||
if (leftHanded == 1) {
|
||||
if (inLeftHandedMode == leftHanded) {
|
||||
return;
|
||||
}
|
||||
|
||||
//send command struct again with changes
|
||||
if (leftHanded) {
|
||||
OLED_Setup_Array[11] = 0xC8; //c1?
|
||||
OLED_Setup_Array[19] = 0xA1;
|
||||
} else if (leftHanded == 0) {
|
||||
} else {
|
||||
OLED_Setup_Array[11] = 0xC0;
|
||||
OLED_Setup_Array[19] = 0xA0;
|
||||
}
|
||||
taskENTER_CRITICAL();
|
||||
|
||||
HAL_I2C_Master_Transmit(i2c, DEVICEADDR_OLED,
|
||||
(uint8_t*) OLED_Setup_Array, 50, 0xFFFF);
|
||||
taskEXIT_CRITICAL();
|
||||
i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array, sizeof(OLED_Setup_Array));
|
||||
inLeftHandedMode = leftHanded;
|
||||
|
||||
screenBuffer[5] = inLeftHandedMode ? 0 : 32; //display is shifted by 32 in left handed mode as driver ram is 128 wide
|
||||
screenBuffer[7] = inLeftHandedMode ? 95 : 0x7F; //End address of the ram segment we are writing to (96 wide)
|
||||
screenBuffer[9] = inLeftHandedMode ? 0xC8 : 0xC0;
|
||||
}
|
||||
}
|
||||
|
||||
//print a string to the current cursor location
|
||||
void OLED::print(const char* str) {
|
||||
@@ -203,14 +171,6 @@ void OLED::print(const char* str) {
|
||||
}
|
||||
}
|
||||
|
||||
void OLED::setCursor(int16_t x, int16_t y) {
|
||||
cursor_x = x;
|
||||
cursor_y = y;
|
||||
}
|
||||
void OLED::setCharCursor(int16_t x, int16_t y) {
|
||||
cursor_x = x * fontWidth;
|
||||
cursor_y = y * fontHeight;
|
||||
}
|
||||
void OLED::setFont(uint8_t fontNumber) {
|
||||
if (fontNumber == 1) {
|
||||
//small font
|
||||
@@ -228,58 +188,35 @@ void OLED::setFont(uint8_t fontNumber) {
|
||||
}
|
||||
}
|
||||
|
||||
void OLED::drawImage(const uint8_t* buffer, uint8_t x, uint8_t width) {
|
||||
drawArea(x, 0, width, 16, buffer);
|
||||
}
|
||||
|
||||
//maximum places is 5
|
||||
void OLED::printNumber(uint16_t number, uint8_t places) {
|
||||
char buffer[6];
|
||||
buffer[5] = 0; //null
|
||||
char buffer[6] = { 0 };
|
||||
|
||||
if (places == 5) {
|
||||
buffer[4] = '0' + number % 10;
|
||||
number /= 10;
|
||||
} else
|
||||
buffer[4] = 0;
|
||||
}
|
||||
|
||||
if (places > 3) {
|
||||
buffer[3] = '0' + number % 10;
|
||||
number /= 10;
|
||||
} else
|
||||
buffer[3] = 0;
|
||||
}
|
||||
|
||||
if (places > 2) {
|
||||
buffer[2] = '0' + number % 10;
|
||||
number /= 10;
|
||||
} else
|
||||
buffer[2] = 0;
|
||||
}
|
||||
|
||||
if (places > 1) {
|
||||
buffer[1] = '0' + number % 10;
|
||||
number /= 10;
|
||||
} else
|
||||
buffer[1] = 0;
|
||||
}
|
||||
|
||||
buffer[0] = '0' + number % 10;
|
||||
number /= 10;
|
||||
print(buffer);
|
||||
}
|
||||
|
||||
void OLED::clearScreen() {
|
||||
memset(firstStripPtr, 0, 96);
|
||||
memset(secondStripPtr, 0, 96);
|
||||
}
|
||||
|
||||
bool OLED::getRotation() {
|
||||
return inLeftHandedMode;
|
||||
}
|
||||
void OLED::drawBattery(uint8_t state) {
|
||||
if (state > 10)
|
||||
state = 10;
|
||||
drawSymbol(3 + state);
|
||||
}
|
||||
void OLED::drawCheckbox(bool state) {
|
||||
drawSymbol((state) ? 17 : 18);
|
||||
}
|
||||
void OLED::drawSymbol(uint8_t symbolID) {
|
||||
//draw a symbol to the current cursor location
|
||||
setFont(2);
|
||||
@@ -300,11 +237,11 @@ void OLED::drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
||||
uint8_t visibleEnd = wide;
|
||||
|
||||
// trimming to draw partials
|
||||
if(x < 0) {
|
||||
visibleStart -= x; //subtract negative value == add absolute value
|
||||
if (x < 0) {
|
||||
visibleStart -= x; //subtract negative value == add absolute value
|
||||
}
|
||||
if(x + wide > 96) {
|
||||
visibleEnd = 96 - x;
|
||||
if (x + wide > 96) {
|
||||
visibleEnd = 96 - x;
|
||||
}
|
||||
|
||||
if (y == 0) {
|
||||
@@ -320,3 +257,81 @@ void OLED::drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
||||
}
|
||||
}
|
||||
}
|
||||
void OLED::fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
||||
const uint8_t value) {
|
||||
// Splat this from x->x+wide in two strides
|
||||
if (x <= -wide)
|
||||
return; //cutoffleft
|
||||
if (x > 96)
|
||||
return; //cutoff right
|
||||
|
||||
uint8_t visibleStart = 0;
|
||||
uint8_t visibleEnd = wide;
|
||||
|
||||
// trimming to draw partials
|
||||
if (x < 0) {
|
||||
visibleStart -= x; //subtract negative value == add absolute value
|
||||
}
|
||||
if (x + wide > 96) {
|
||||
visibleEnd = 96 - x;
|
||||
}
|
||||
|
||||
if (y == 0) {
|
||||
//Splat first line of data
|
||||
for (uint8_t xx = visibleStart; xx < visibleEnd; xx++) {
|
||||
firstStripPtr[xx + x] = value;
|
||||
}
|
||||
}
|
||||
if (y == 8 || height == 16) {
|
||||
// Splat the second line
|
||||
for (uint8_t xx = visibleStart; xx < visibleEnd; xx++) {
|
||||
secondStripPtr[x + xx] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OLED::drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
|
||||
bool clear) {
|
||||
//Draw this in 3 sections
|
||||
//This is basically a N wide version of vertical line
|
||||
|
||||
//Step 1 : Draw in the top few pixels that are not /8 aligned
|
||||
//LSB is at the top of the screen
|
||||
uint8_t mask = 0xFF;
|
||||
if (y0) {
|
||||
mask = mask << (y0 % 8);
|
||||
for (uint8_t col = x0; col < x1; col++)
|
||||
if (clear)
|
||||
firstStripPtr[(y0 / 8) * 96 + col] &= ~mask;
|
||||
else
|
||||
firstStripPtr[(y0 / 8) * 96 + col] |= mask;
|
||||
}
|
||||
//Next loop down the line the total number of solids
|
||||
if (y0 / 8 != y1 / 8)
|
||||
for (uint8_t col = x0; col < x1; col++)
|
||||
for (uint8_t r = (y0 / 8); r < (y1 / 8); r++) {
|
||||
//This gives us the row index r
|
||||
if (clear)
|
||||
firstStripPtr[(r * 96) + col] = 0;
|
||||
else
|
||||
firstStripPtr[(r * 96) + col] = 0xFF;
|
||||
}
|
||||
|
||||
//Finally draw the tail
|
||||
mask = ~(mask << (y1 % 8));
|
||||
for (uint8_t col = x0; col < x1; col++)
|
||||
if (clear)
|
||||
firstStripPtr[(y1 / 8) * 96 + col] &= ~mask;
|
||||
else
|
||||
firstStripPtr[(y1 / 8) * 96 + col] |= mask;
|
||||
}
|
||||
|
||||
void OLED::drawHeatSymbol(uint8_t state) {
|
||||
//Draw symbol 14
|
||||
//Then draw over it botom 5 pixels always stay. 8 pixels above that are the levels
|
||||
state /= 12; // 0-> 8 range
|
||||
//Then we want to draw down (16-(5+state)
|
||||
uint8_t cursor_x_temp = cursor_x;
|
||||
drawSymbol(14);
|
||||
drawFilledRect(cursor_x_temp, 0, cursor_x_temp + 12, 2 + (8 - state), true);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,10 @@ void resetSettings() {
|
||||
systemSettings.CalibrationOffset = 10; //This appears to be quite close for both of my tips, in both of my handles
|
||||
systemSettings.temperatureInF = 0; //default to 0
|
||||
systemSettings.descriptionScrollSpeed=0;//default to slow
|
||||
systemSettings.PID_P =42;
|
||||
systemSettings.PID_I =50;
|
||||
systemSettings.PID_D =15;
|
||||
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ ADC_HandleTypeDef hadc1;
|
||||
DMA_HandleTypeDef hdma_adc1;
|
||||
|
||||
I2C_HandleTypeDef hi2c1;
|
||||
DMA_HandleTypeDef hdma_i2c1_rx;
|
||||
DMA_HandleTypeDef hdma_i2c1_tx;
|
||||
|
||||
IWDG_HandleTypeDef hiwdg;
|
||||
TIM_HandleTypeDef htim2;
|
||||
@@ -36,7 +38,7 @@ void Setup_HAL() {
|
||||
MX_TIM2_Init();
|
||||
MX_IWDG_Init();
|
||||
|
||||
HAL_ADC_Start_DMA(&hadc1, (uint32_t*) ADCReadings, 64);//start DMA of normal readings
|
||||
HAL_ADC_Start_DMA(&hadc1, (uint32_t*) ADCReadings, 64); //start DMA of normal readings
|
||||
HAL_ADCEx_InjectedStart(&hadc1); //enable injected readings
|
||||
}
|
||||
|
||||
@@ -75,7 +77,7 @@ void SystemClock_Config(void) {
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV16; //TIM 2,3,4,5,6,7,12,13,14
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; //64 mhz to soem peripherals and adc
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; //64 mhz to some peripherals and adc
|
||||
|
||||
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
|
||||
|
||||
@@ -129,31 +131,39 @@ static void MX_ADC1_Init(void) {
|
||||
//F in = 10.66 MHz
|
||||
/*
|
||||
* Injected time is 1 delay clock + (12 adc cycles*4)+4*sampletime =~217 clocks = 0.2ms
|
||||
*
|
||||
* Charge time is 0.016 uS ideally
|
||||
* So Sampling time must be >= 0.016uS
|
||||
* 1/10.66MHz is 0.09uS, so 1 CLK is *should* be enough
|
||||
* */
|
||||
sConfigInjected.InjectedChannel = ADC_CHANNEL_8;
|
||||
sConfigInjected.InjectedRank = 1;
|
||||
sConfigInjected.InjectedNbrOfConversion = 4;
|
||||
sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_13CYCLES_5;
|
||||
sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_7CYCLES_5;
|
||||
sConfigInjected.ExternalTrigInjecConv = ADC_EXTERNALTRIGINJECCONV_T2_CC1;
|
||||
sConfigInjected.AutoInjectedConv = DISABLE;
|
||||
sConfigInjected.InjectedDiscontinuousConvMode = DISABLE;
|
||||
sConfigInjected.InjectedOffset = 0;
|
||||
|
||||
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
||||
|
||||
sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_1CYCLE_5;
|
||||
sConfigInjected.InjectedRank = 2;
|
||||
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
||||
sConfigInjected.InjectedRank = 3;
|
||||
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
||||
sConfigInjected.InjectedRank = 4;
|
||||
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
||||
//SET_BIT(hadc1.Instance->CR1, ( ADC_CR1_JEOCIE ));//Enable end of injected conv irq
|
||||
SET_BIT(hadc1.Instance->CR1, ( ADC_CR1_JEOCIE )); //Enable end of injected conv irq
|
||||
// Run ADC internal calibration
|
||||
while (HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK)
|
||||
;
|
||||
}
|
||||
|
||||
/* I2C1 init function */
|
||||
static void MX_I2C1_Init(void) {
|
||||
|
||||
hi2c1.Instance = I2C1;
|
||||
hi2c1.Init.ClockSpeed = 300000; //200Khz
|
||||
hi2c1.Init.ClockSpeed = 100000; // OLED doesnt handle >100k when its asleep (off).
|
||||
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
|
||||
hi2c1.Init.OwnAddress1 = 0;
|
||||
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||
@@ -256,7 +266,7 @@ static void MX_TIM2_Init(void) {
|
||||
/*
|
||||
* It takes 4 milliseconds for output to be stable after PWM turns off.
|
||||
* Assume ADC samples in 0.5ms
|
||||
* We need to set this to 100% + 4.5ms
|
||||
* We need to set this to 100% + 5.5ms
|
||||
* */
|
||||
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||
sConfigOC.OCFastMode = TIM_OCFAST_ENABLE;
|
||||
@@ -285,13 +295,13 @@ static void MX_DMA_Init(void) {
|
||||
|
||||
/* DMA interrupt init */
|
||||
/* DMA1_Channel1_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 5, 0);
|
||||
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 15, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
|
||||
/* DMA1_Channel6_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 5, 0);
|
||||
HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 15, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
|
||||
/* DMA1_Channel7_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 5, 0);
|
||||
HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 15, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn);
|
||||
|
||||
}
|
||||
@@ -333,13 +343,16 @@ static void MX_GPIO_Init(void) {
|
||||
| GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
//Set PA 11 and PA 12 to GND to stop usb detection, 14 re-rused for debug
|
||||
|
||||
//Set PA 11 and PA 12 to GND to stop usb detection, 13/14 re-rused for debug
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14 | GPIO_PIN_13;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_14, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pins : KEY_B_Pin KEY_A_Pin */
|
||||
GPIO_InitStruct.Pin = KEY_B_Pin | KEY_A_Pin;
|
||||
@@ -358,10 +371,11 @@ static void MX_GPIO_Init(void) {
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(OLED_RESET_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : INT_Orientation_Pin INT_Movement_Pin */
|
||||
/* Configure GPIO pins : INT_Orientation_Pin INT_Movement_Pin */
|
||||
/* Not used anymore*/
|
||||
GPIO_InitStruct.Pin = INT_Orientation_Pin | INT_Movement_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP; //Technically the IMU is P-P but safer to pullup (very tiny current cost)
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/*Configure peripheral I/O remapping */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,15 @@ static void settings_setAdvancedIDLEScreens(void);
|
||||
static void settings_displayAdvancedIDLEScreens(void);
|
||||
static void settings_setScrollSpeed(void);
|
||||
static void settings_displayScrollSpeed(void);
|
||||
#ifdef PIDSETTINGS
|
||||
|
||||
static void settings_setPIDP(void);
|
||||
static void settings_displayPIDP(void);
|
||||
static void settings_setPIDI(void);
|
||||
static void settings_displayPIDI(void);
|
||||
static void settings_setPIDD(void);
|
||||
static void settings_displayPIDD(void);
|
||||
#endif
|
||||
static void settings_setDisplayRotation(void);
|
||||
static void settings_displayDisplayRotation(void);
|
||||
static void settings_setBoostModeEnabled(void);
|
||||
@@ -181,7 +189,16 @@ const menuitem advancedMenu[] = {
|
||||
settings_displayCalibrate } }, /*Calibrate tip*/
|
||||
{ (const char*) SettingsDescriptions[14], { settings_setCalibrateVIN }, {
|
||||
settings_displayCalibrateVIN } }, /*Voltage input cal*/
|
||||
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
|
||||
#ifdef PIDSETTINGS
|
||||
|
||||
{ (const char*) SettingsDescriptions[17], {settings_setPIDP}, {
|
||||
settings_displayPIDP}}, /*Voltage input cal*/
|
||||
{ (const char*) SettingsDescriptions[18], {settings_setPIDI}, {
|
||||
settings_displayPIDI}}, /*Voltage input cal*/
|
||||
{ (const char*) SettingsDescriptions[19], {settings_setPIDD}, {
|
||||
settings_displayPIDD}}, /*Voltage input cal*/
|
||||
#endif
|
||||
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
|
||||
};
|
||||
|
||||
static void printShortDescriptionSingleLine(uint32_t shortDescIndex) {
|
||||
@@ -262,7 +279,7 @@ static int userConfirmation(const char* message) {
|
||||
|
||||
if (lcdRefresh) {
|
||||
lcd.refresh();
|
||||
osDelay(20);
|
||||
osDelay(40);
|
||||
lcdRefresh = false;
|
||||
}
|
||||
}
|
||||
@@ -363,13 +380,13 @@ static void settings_setTempF(void) {
|
||||
|
||||
}
|
||||
// Rescale both to be multiples of 10
|
||||
systemSettings.BoostTemp = systemSettings.BoostTemp/10;
|
||||
systemSettings.BoostTemp *=10;
|
||||
systemSettings.SolderingTemp = systemSettings.SolderingTemp/10;
|
||||
systemSettings.SolderingTemp *=10;
|
||||
systemSettings.SleepTemp = systemSettings.SleepTemp/10;
|
||||
systemSettings.SleepTemp *=10;
|
||||
|
||||
systemSettings.BoostTemp = systemSettings.BoostTemp / 10;
|
||||
systemSettings.BoostTemp *= 10;
|
||||
systemSettings.SolderingTemp = systemSettings.SolderingTemp / 10;
|
||||
systemSettings.SolderingTemp *= 10;
|
||||
systemSettings.SleepTemp = systemSettings.SleepTemp / 10;
|
||||
systemSettings.SleepTemp *= 10;
|
||||
|
||||
}
|
||||
|
||||
static void settings_displayTempF(void) {
|
||||
@@ -488,6 +505,33 @@ static void settings_displayBoostTemp(void) {
|
||||
lcd.printNumber(systemSettings.BoostTemp, 3);
|
||||
}
|
||||
|
||||
#ifdef PIDSETTINGS
|
||||
static void settings_setPIDP(void) {
|
||||
systemSettings.PID_P++;
|
||||
systemSettings.PID_P %= 100;
|
||||
}
|
||||
static void settings_displayPIDP(void) {
|
||||
printShortDescription(17, 6);
|
||||
lcd.printNumber(systemSettings.PID_P, 2);
|
||||
}
|
||||
static void settings_setPIDI(void) {
|
||||
systemSettings.PID_I++;
|
||||
systemSettings.PID_I %= 100;
|
||||
}
|
||||
static void settings_displayPIDI(void) {
|
||||
printShortDescription(18, 6);
|
||||
lcd.printNumber(systemSettings.PID_I, 2);
|
||||
}
|
||||
static void settings_setPIDD(void) {
|
||||
systemSettings.PID_D++;
|
||||
systemSettings.PID_D %= 100;
|
||||
}
|
||||
static void settings_displayPIDD(void) {
|
||||
printShortDescription(19, 6);
|
||||
lcd.printNumber(systemSettings.PID_D, 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void settings_setAutomaticStartMode(void) {
|
||||
systemSettings.autoStartMode++;
|
||||
systemSettings.autoStartMode %= 2;
|
||||
@@ -495,7 +539,6 @@ static void settings_setAutomaticStartMode(void) {
|
||||
|
||||
static void settings_displayAutomaticStartMode(void) {
|
||||
printShortDescription(10, 7);
|
||||
|
||||
lcd.drawCheckbox(systemSettings.autoStartMode);
|
||||
}
|
||||
|
||||
@@ -585,14 +628,14 @@ static void settings_setCalibrateVIN(void) {
|
||||
case BUTTON_B_LONG:
|
||||
saveSettings();
|
||||
return;
|
||||
|
||||
break;
|
||||
case BUTTON_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
lcd.refresh();
|
||||
osDelay(50);
|
||||
osDelay(40);
|
||||
|
||||
// Cap to sensible values
|
||||
if (systemSettings.voltageDiv < 90) {
|
||||
@@ -603,55 +646,40 @@ static void settings_setCalibrateVIN(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void settings_displayCalibrateVIN(void) {
|
||||
printShortDescription(14, 5);
|
||||
}
|
||||
static void settings_displaySolderingMenu(void) {
|
||||
static void displayMenu(size_t index) {
|
||||
//Call into the menu
|
||||
lcd.setFont(1);
|
||||
lcd.setCursor(0, 0);
|
||||
//Draw title
|
||||
lcd.print(SettingsMenuEntries[0]);
|
||||
lcd.print(SettingsMenuEntries[index]);
|
||||
//Draw symbol
|
||||
//16 pixel wide image
|
||||
lcd.drawArea(96 - 16, 0, 16, 16, (&SettingsMenuIcons[(16 * 2) * 0]));
|
||||
lcd.drawArea(96 - 16, 0, 16, 16, (&SettingsMenuIcons[(16 * 2) * index]));
|
||||
}
|
||||
|
||||
static void settings_displayCalibrateVIN(void) {
|
||||
printShortDescription(14, 5);
|
||||
}
|
||||
static void settings_displaySolderingMenu(void) {
|
||||
displayMenu(0);
|
||||
}
|
||||
static void settings_enterSolderingMenu(void) {
|
||||
gui_Menu(solderingMenu);
|
||||
}
|
||||
static void settings_displayPowerMenu(void) {
|
||||
lcd.setFont(1);
|
||||
lcd.setCursor(0, 0);
|
||||
//Draw title
|
||||
lcd.print(SettingsMenuEntries[1]);
|
||||
//Draw symbol
|
||||
//16 pixel wide image
|
||||
lcd.drawArea(96 - 16, 0, 16, 16, (&SettingsMenuIcons[(16 * 2) * 1]));
|
||||
displayMenu(1);
|
||||
}
|
||||
static void settings_enterPowerMenu(void) {
|
||||
gui_Menu(PowerMenu);
|
||||
}
|
||||
static void settings_displayUIMenu(void) {
|
||||
lcd.setFont(1);
|
||||
lcd.setCursor(0, 0);
|
||||
//Draw title
|
||||
lcd.print(SettingsMenuEntries[2]);
|
||||
//Draw symbol
|
||||
//16 pixel wide image
|
||||
lcd.drawArea(96 - 16, 0, 16, 16, (&SettingsMenuIcons[(16 * 2) * 2]));
|
||||
displayMenu(2);
|
||||
}
|
||||
static void settings_enterUIMenu(void) {
|
||||
gui_Menu(UIMenu);
|
||||
}
|
||||
static void settings_displayAdvancedMenu(void) {
|
||||
lcd.setFont(1);
|
||||
lcd.setCursor(0, 0);
|
||||
//Draw title
|
||||
lcd.print(SettingsMenuEntries[3]);
|
||||
//Draw symbol
|
||||
//16 pixel wide image
|
||||
lcd.drawArea(96 - 16, 0, 16, 16, (&SettingsMenuIcons[(16 * 2) * 3]));
|
||||
|
||||
displayMenu(3);
|
||||
}
|
||||
static void settings_enterAdvancedMenu(void) {
|
||||
gui_Menu(advancedMenu);
|
||||
@@ -764,7 +792,7 @@ void gui_Menu(const menuitem* menu) {
|
||||
|
||||
if (lcdRefresh) {
|
||||
lcd.refresh(); // update the LCD
|
||||
osDelay(20);
|
||||
osDelay(40);
|
||||
lcdRefresh = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,35 +60,20 @@ uint16_t getTipInstantTemperature() {
|
||||
|
||||
}
|
||||
uint16_t getTipRawTemp(uint8_t instant) {
|
||||
#define filterDepth1 1
|
||||
/*Pre filter used before PID*/
|
||||
#define filterDepth2 48
|
||||
/*Post filter used for UI display*/
|
||||
static uint16_t filterLayer1[filterDepth1];
|
||||
static uint16_t filterLayer2[filterDepth2];
|
||||
static uint8_t index = 0;
|
||||
static uint8_t indexFilter = 0;
|
||||
static int64_t filterFP = 0;
|
||||
const uint8_t filterBeta = 5; //higher values smooth out more, but reduce responsiveness
|
||||
|
||||
if (instant) {
|
||||
if (instant == 1) {
|
||||
uint16_t itemp = getTipInstantTemperature();
|
||||
filterLayer1[index] = itemp;
|
||||
index = (index + 1) % filterDepth1;
|
||||
uint32_t total = 0;
|
||||
for (uint8_t i = 0; i < filterDepth1; i++)
|
||||
total += filterLayer1[i];
|
||||
|
||||
return total / filterDepth1;
|
||||
filterFP = (filterFP << filterBeta) - filterFP;
|
||||
filterFP += (itemp << 9);
|
||||
filterFP = filterFP >> filterBeta;
|
||||
return itemp;
|
||||
} else if (instant == 2) {
|
||||
filterFP = (getTipInstantTemperature() << 9);
|
||||
return filterFP >> 9;
|
||||
} else {
|
||||
uint32_t total = 0;
|
||||
for (uint8_t i = 0; i < filterDepth1; i++)
|
||||
total += filterLayer1[i];
|
||||
filterLayer2[indexFilter] = total / filterDepth1;
|
||||
indexFilter = (indexFilter + 1) % filterDepth2;
|
||||
total = 0;
|
||||
for (uint8_t i = 0; i < filterDepth2; i++)
|
||||
total += filterLayer2[i];
|
||||
|
||||
return total / filterDepth2;
|
||||
return filterFP >> 9;
|
||||
}
|
||||
}
|
||||
uint16_t getInputVoltageX10(uint8_t divisor) {
|
||||
@@ -120,15 +105,10 @@ uint8_t getTipPWM() {
|
||||
return htim2.Instance->CCR4;
|
||||
}
|
||||
void setTipPWM(uint8_t pulse) {
|
||||
PWMSafetyTimer = 640; //This is decremented in the handler for PWM so that the tip pwm is disabled if the PID task is not scheduled often enough.
|
||||
PWMSafetyTimer = 2; //This is decremented in the handler for PWM so that the tip pwm is disabled if the PID task is not scheduled often enough.
|
||||
if (pulse > 100)
|
||||
pulse = 100;
|
||||
if (pulse) {
|
||||
htim2.Instance->CCR4 = pulse;
|
||||
} else {
|
||||
htim2.Instance->CCR4 = 0;
|
||||
}
|
||||
|
||||
htim2.Instance->CCR4 = pulse;
|
||||
}
|
||||
|
||||
//Thse are called by the HAL after the corresponding events from the system timers.
|
||||
@@ -138,7 +118,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||
if (htim->Instance == TIM2) {
|
||||
//we want to turn on the output again
|
||||
PWMSafetyTimer--; //We decrement this safety value so that lockups in the scheduler will not cause the PWM to become locked in an active driving state.
|
||||
//While we could assume this could never happened, its a small price for increased safety
|
||||
//While we could assume this could never happen, its a small price for increased safety
|
||||
if (htim2.Instance->CCR4 && PWMSafetyTimer) {
|
||||
htim3.Instance->CCR1 = 50;
|
||||
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
|
||||
@@ -159,12 +139,9 @@ void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) {
|
||||
htim3.Instance->CCR1 = 0;
|
||||
|
||||
} /*else if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) {
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_14, GPIO_PIN_RESET);
|
||||
}*/
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_14, GPIO_PIN_RESET);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc) {
|
||||
|
||||
}
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
#include "string.h"
|
||||
#include "LIS2DH12.hpp"
|
||||
#include <gui.hpp>
|
||||
#include "FRToSI2C.hpp"
|
||||
|
||||
#define ACCELDEBUG 0
|
||||
// C++ objects
|
||||
OLED lcd(&hi2c1);
|
||||
MMA8652FC accel(&hi2c1);
|
||||
LIS2DH12 accel2(&hi2c1);
|
||||
FRToSI2C i2cDev(&hi2c1);
|
||||
OLED lcd(&i2cDev);
|
||||
MMA8652FC accel(&i2cDev);
|
||||
LIS2DH12 accel2(&i2cDev);
|
||||
uint8_t PCBVersion = 0;
|
||||
// File local variables
|
||||
uint16_t currentlyActiveTemperatureTarget = 0;
|
||||
@@ -25,15 +27,13 @@ uint32_t lastButtonTime = 0;
|
||||
// FreeRTOS variables
|
||||
osThreadId GUITaskHandle;
|
||||
osThreadId PIDTaskHandle;
|
||||
osThreadId ROTTaskHandle;
|
||||
osThreadId MOVTaskHandle;
|
||||
SemaphoreHandle_t rotationChangedSemaphore = NULL;
|
||||
SemaphoreHandle_t accelDataAvailableSemaphore = NULL;
|
||||
|
||||
static TaskHandle_t pidTaskNotification = NULL;
|
||||
|
||||
void startGUITask(void const *argument);
|
||||
void startPIDTask(void const *argument);
|
||||
void startMOVTask(void const *argument);
|
||||
void startRotationTask(void const *argument);
|
||||
// End FreeRTOS
|
||||
|
||||
// Main sets up the hardware then hands over to the FreeRTOS kernel
|
||||
@@ -42,6 +42,7 @@ int main(void) {
|
||||
*/
|
||||
HAL_Init();
|
||||
Setup_HAL(); // Setup all the HAL objects
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
setTipPWM(0);
|
||||
lcd.initialize(); // start up the LCD
|
||||
lcd.setFont(0); // default to bigger font
|
||||
@@ -62,7 +63,7 @@ int main(void) {
|
||||
PCBVersion = 3;
|
||||
systemSettings.SleepTime = 0;
|
||||
systemSettings.ShutdownTime = 0; //No accel -> disable sleep
|
||||
systemSettings.sensitivity=0;
|
||||
systemSettings.sensitivity = 0;
|
||||
}
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
restoreSettings(); // load the settings from flash
|
||||
@@ -78,18 +79,11 @@ int main(void) {
|
||||
osThreadDef(PIDTask, startPIDTask, osPriorityRealtime, 0, 512); //2k
|
||||
PIDTaskHandle = osThreadCreate(osThread(PIDTask), NULL);
|
||||
if (PCBVersion != 3) {
|
||||
/* definition and creation of ROTTask */
|
||||
osThreadDef(ROTTask, startRotationTask, osPriorityLow, 0, 256); //1k
|
||||
ROTTaskHandle = osThreadCreate(osThread(ROTTask), NULL);
|
||||
/* definition and creation of MOVTask */
|
||||
osThreadDef(MOVTask, startMOVTask, osPriorityNormal, 0, 512); //2k
|
||||
MOVTaskHandle = osThreadCreate(osThread(MOVTask), NULL);
|
||||
}
|
||||
/* Create the objects*/
|
||||
rotationChangedSemaphore = xSemaphoreCreateBinary();
|
||||
// Used to unlock rotation thread
|
||||
accelDataAvailableSemaphore = xSemaphoreCreateBinary();
|
||||
// Used to unlock the movement thread
|
||||
|
||||
/* Start scheduler */
|
||||
osKernelStart();
|
||||
|
||||
@@ -97,10 +91,15 @@ int main(void) {
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
void GUIDelay() {
|
||||
osDelay(50); // 20Hz
|
||||
void printVoltage() {
|
||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2);
|
||||
lcd.drawChar('.');
|
||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1);
|
||||
}
|
||||
void gui_drawTipTemp() {
|
||||
void GUIDelay() {
|
||||
osDelay(50);
|
||||
}
|
||||
void gui_drawTipTemp(bool symbol) {
|
||||
// Draw tip temp handling unit conversion & tolerance near setpoint
|
||||
uint16_t Temp = getTipRawTemp(0);
|
||||
|
||||
@@ -113,6 +112,12 @@ void gui_drawTipTemp() {
|
||||
// Temp = systemSettings.SolderingTemp;
|
||||
|
||||
lcd.printNumber(Temp, 3); // Draw the tip temp out finally
|
||||
if (symbol) {
|
||||
if (systemSettings.temperatureInF)
|
||||
lcd.print("F");
|
||||
else
|
||||
lcd.print("C");
|
||||
}
|
||||
}
|
||||
ButtonState getButtonState() {
|
||||
/*
|
||||
@@ -188,13 +193,13 @@ static void waitForButtonPress() {
|
||||
ButtonState buttons = getButtonState();
|
||||
while (buttons) {
|
||||
buttons = getButtonState();
|
||||
GUIDelay();
|
||||
lcd.refresh();
|
||||
GUIDelay();
|
||||
}
|
||||
while (!buttons) {
|
||||
buttons = getButtonState();
|
||||
GUIDelay();
|
||||
lcd.refresh();
|
||||
GUIDelay();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,11 +227,7 @@ static bool checkVoltageForExit() {
|
||||
lcd.print(UndervoltageString);
|
||||
lcd.setCursor(0, 8);
|
||||
lcd.print(InputVoltageString);
|
||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
|
||||
2);
|
||||
lcd.drawChar('.');
|
||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
|
||||
1);
|
||||
printVoltage();
|
||||
lcd.print("V");
|
||||
|
||||
} else {
|
||||
@@ -257,11 +258,13 @@ static void gui_drawBatteryIcon() {
|
||||
cellV = 9;
|
||||
lcd.drawBattery(cellV + 1);
|
||||
} else
|
||||
lcd.drawSymbol(16); // Draw the DC Logo
|
||||
lcd.drawSymbol(15); // Draw the DC Logo
|
||||
}
|
||||
static void gui_solderingTempAdjust() {
|
||||
uint32_t lastChange = xTaskGetTickCount();
|
||||
currentlyActiveTemperatureTarget = 0;
|
||||
uint32_t autoRepeatTimer = 0;
|
||||
uint8_t autoRepeatAcceleration = 0;
|
||||
for (;;) {
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.clearScreen();
|
||||
@@ -278,10 +281,30 @@ static void gui_solderingTempAdjust() {
|
||||
return;
|
||||
break;
|
||||
case BUTTON_B_LONG:
|
||||
if (xTaskGetTickCount() - autoRepeatTimer
|
||||
+ autoRepeatAcceleration> PRESS_ACCEL_INTERVAL_MAX) {
|
||||
if (!lcd.getRotation()) {
|
||||
systemSettings.SolderingTemp += 10; // add 10
|
||||
} else {
|
||||
systemSettings.SolderingTemp -= 10; // sub 10
|
||||
}
|
||||
autoRepeatTimer = xTaskGetTickCount();
|
||||
|
||||
autoRepeatAcceleration += PRESS_ACCEL_STEP;
|
||||
}
|
||||
break;
|
||||
case BUTTON_F_LONG:
|
||||
if (xTaskGetTickCount() - autoRepeatTimer
|
||||
+ autoRepeatAcceleration> PRESS_ACCEL_INTERVAL_MAX) {
|
||||
if (!lcd.getRotation()) {
|
||||
systemSettings.SolderingTemp -= 10;
|
||||
} else {
|
||||
systemSettings.SolderingTemp += 10;
|
||||
}
|
||||
autoRepeatTimer = xTaskGetTickCount();
|
||||
|
||||
autoRepeatAcceleration += PRESS_ACCEL_STEP;
|
||||
}
|
||||
break;
|
||||
case BUTTON_F_SHORT:
|
||||
if (lcd.getRotation()) {
|
||||
@@ -300,6 +323,11 @@ static void gui_solderingTempAdjust() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ((PRESS_ACCEL_INTERVAL_MAX - autoRepeatAcceleration)
|
||||
< PRESS_ACCEL_INTERVAL_MIN) {
|
||||
autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX
|
||||
- PRESS_ACCEL_INTERVAL_MIN;
|
||||
}
|
||||
// constrain between 50-450 C
|
||||
if (systemSettings.temperatureInF) {
|
||||
if (systemSettings.SolderingTemp > 850)
|
||||
@@ -333,56 +361,6 @@ static void gui_solderingTempAdjust() {
|
||||
}
|
||||
}
|
||||
|
||||
static int gui_showTipTempWarning() {
|
||||
for (;;) {
|
||||
uint16_t tipTemp = tipMeasurementToC(getTipRawTemp(0));
|
||||
lcd.clearScreen();
|
||||
lcd.setCursor(0, 0);
|
||||
if (systemSettings.detailedSoldering) {
|
||||
lcd.setFont(1);
|
||||
lcd.print(WarningAdvancedString);
|
||||
lcd.setCursor(0, 8);
|
||||
lcd.print(WarningTipTempString);
|
||||
|
||||
if (systemSettings.temperatureInF) {
|
||||
lcd.printNumber(tipMeasurementToF(getTipRawTemp(0)), 3);
|
||||
lcd.print("F");
|
||||
} else {
|
||||
lcd.printNumber(tipMeasurementToC(getTipRawTemp(0)), 3);
|
||||
lcd.print("C");
|
||||
}
|
||||
} else {
|
||||
lcd.setFont(0);
|
||||
lcd.drawArea(0, 0, 24, 16, WarningBlock24);
|
||||
lcd.setCursor(24, 0);
|
||||
// lcd.print(WarningSimpleString);
|
||||
lcd.print(" ");
|
||||
if (systemSettings.temperatureInF) {
|
||||
lcd.printNumber(tipMeasurementToF(getTipRawTemp(0)), 3);
|
||||
lcd.drawSymbol(0);
|
||||
} else {
|
||||
lcd.printNumber(tipMeasurementToC(getTipRawTemp(0)), 3);
|
||||
lcd.drawSymbol(1);
|
||||
}
|
||||
}
|
||||
if (systemSettings.coolingTempBlink && tipTemp > 70) {
|
||||
if (xTaskGetTickCount() % 50 < 25)
|
||||
lcd.clearScreen();
|
||||
}
|
||||
lcd.refresh();
|
||||
ButtonState buttons = getButtonState();
|
||||
if (buttons == BUTTON_F_SHORT)
|
||||
return 1;
|
||||
else if (buttons == BUTTON_B_SHORT || buttons == BUTTON_BOTH)
|
||||
return 0;
|
||||
|
||||
if (tipTemp < 50)
|
||||
return 0; //Exit the warning screen
|
||||
|
||||
GUIDelay();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static uint16_t min(uint16_t a, uint16_t b) {
|
||||
if (a > b)
|
||||
return b;
|
||||
@@ -402,14 +380,15 @@ static int gui_SolderingSleepingMode() {
|
||||
if (checkVoltageForExit())
|
||||
return 1; // return non-zero on error
|
||||
|
||||
if (systemSettings.temperatureInF)
|
||||
if (systemSettings.temperatureInF) {
|
||||
currentlyActiveTemperatureTarget = ftoTipMeasurement(
|
||||
min(systemSettings.SleepTemp,
|
||||
systemSettings.SolderingTemp));
|
||||
else
|
||||
} else {
|
||||
currentlyActiveTemperatureTarget = ctoTipMeasurement(
|
||||
min(systemSettings.SleepTemp,
|
||||
systemSettings.SolderingTemp));
|
||||
}
|
||||
// draw the lcd
|
||||
uint16_t tipTemp;
|
||||
if (systemSettings.temperatureInF)
|
||||
@@ -431,11 +410,7 @@ static int gui_SolderingSleepingMode() {
|
||||
lcd.print("C");
|
||||
|
||||
lcd.print(" ");
|
||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
|
||||
2);
|
||||
lcd.drawChar('.');
|
||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
|
||||
1);
|
||||
printVoltage();
|
||||
lcd.drawChar('V');
|
||||
} else {
|
||||
lcd.setFont(0);
|
||||
@@ -531,24 +506,9 @@ static void gui_solderingMode() {
|
||||
|
||||
lcd.setCursor(0, 8);
|
||||
lcd.print(SleepingTipAdvancedString);
|
||||
uint16_t Temp = getTipRawTemp(0);
|
||||
|
||||
if (systemSettings.temperatureInF)
|
||||
Temp = tipMeasurementToF(Temp);
|
||||
else
|
||||
Temp = tipMeasurementToC(Temp);
|
||||
lcd.printNumber(Temp, 3);
|
||||
if (systemSettings.temperatureInF)
|
||||
lcd.print("F");
|
||||
else
|
||||
lcd.print("C");
|
||||
|
||||
gui_drawTipTemp(true);
|
||||
lcd.print(" ");
|
||||
lcd.printNumber(
|
||||
getInputVoltageX10(systemSettings.voltageDiv) / 10, 2);
|
||||
lcd.drawChar('.');
|
||||
lcd.printNumber(
|
||||
getInputVoltageX10(systemSettings.voltageDiv) % 10, 1);
|
||||
printVoltage();
|
||||
lcd.drawChar('V');
|
||||
} else {
|
||||
// We switch the layout direction depending on the orientation of the lcd.
|
||||
@@ -557,13 +517,7 @@ static void gui_solderingMode() {
|
||||
gui_drawBatteryIcon();
|
||||
|
||||
lcd.drawChar(' '); // Space out gap between battery <-> temp
|
||||
if (systemSettings.temperatureInF) {
|
||||
gui_drawTipTemp(); // Draw current tip temp
|
||||
lcd.drawSymbol(0); // deg F
|
||||
} else {
|
||||
gui_drawTipTemp(); // Draw current tip temp
|
||||
lcd.drawSymbol(1); // deg C
|
||||
}
|
||||
gui_drawTipTemp(true); // Draw current tip temp
|
||||
|
||||
// We draw boost arrow if boosting, or else gap temp <-> heat indicator
|
||||
if (boostModeOn)
|
||||
@@ -572,31 +526,16 @@ static void gui_solderingMode() {
|
||||
lcd.drawChar(' ');
|
||||
|
||||
// Draw heating/cooling symbols
|
||||
// If tip PWM > 10% then we are 'heating'
|
||||
if (getTipPWM() > 10)
|
||||
lcd.drawSymbol(14);
|
||||
else
|
||||
lcd.drawSymbol(15);
|
||||
lcd.drawHeatSymbol(getTipPWM());
|
||||
} else {
|
||||
// Draw heating/cooling symbols
|
||||
// If tip PWM > 10% then we are 'heating'
|
||||
if (getTipPWM() > 10)
|
||||
lcd.drawSymbol(14);
|
||||
else
|
||||
lcd.drawSymbol(15);
|
||||
lcd.drawHeatSymbol(getTipPWM());
|
||||
// We draw boost arrow if boosting, or else gap temp <-> heat indicator
|
||||
if (boostModeOn)
|
||||
lcd.drawSymbol(2);
|
||||
else
|
||||
lcd.drawChar(' ');
|
||||
|
||||
if (systemSettings.temperatureInF) {
|
||||
gui_drawTipTemp(); // Draw current tip temp
|
||||
lcd.drawSymbol(0); // deg F
|
||||
} else {
|
||||
gui_drawTipTemp(); // Draw current tip temp
|
||||
lcd.drawSymbol(1); // deg C
|
||||
}
|
||||
gui_drawTipTemp(true); // Draw current tip temp
|
||||
|
||||
lcd.drawChar(' '); // Space out gap between battery <-> temp
|
||||
|
||||
@@ -624,6 +563,7 @@ static void gui_solderingMode() {
|
||||
|
||||
// Undervoltage test
|
||||
if (checkVoltageForExit()) {
|
||||
lastButtonTime = xTaskGetTickCount();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -632,6 +572,7 @@ static void gui_solderingMode() {
|
||||
if (xTaskGetTickCount() - lastMovementTime > sleepThres
|
||||
&& xTaskGetTickCount() - lastButtonTime > sleepThres) {
|
||||
if (gui_SolderingSleepingMode()) {
|
||||
lastButtonTime = xTaskGetTickCount();
|
||||
return; // If the function returns non-0 then exit
|
||||
}
|
||||
}
|
||||
@@ -639,46 +580,72 @@ static void gui_solderingMode() {
|
||||
}
|
||||
}
|
||||
|
||||
static const char *HEADERS[] = {
|
||||
__DATE__, "Heap: ", "HWMG: ", "HWMP: ", "HWMM: ", "Time: ", "Move: ","Rtip: ","Ctip: ","Vin :" };
|
||||
|
||||
void showVersion(void) {
|
||||
uint8_t screen = 0;
|
||||
ButtonState b;
|
||||
for (;;) {
|
||||
lcd.clearScreen(); // Ensure the buffer starts clean
|
||||
lcd.setCursor(0, 0); // Position the cursor at the 0,0 (top left)
|
||||
lcd.setFont(1); // small font
|
||||
lcd.print((char *) "V2.05 PCB"); // Print version number
|
||||
lcd.printNumber(PCBVersion, 1); //Print PCB ID number
|
||||
lcd.setCursor(0, 8); // second line
|
||||
lcd.print(HEADERS[screen]);
|
||||
switch (screen) {
|
||||
case 1:
|
||||
lcd.printNumber(xPortGetFreeHeapSize(), 5);
|
||||
break;
|
||||
case 2:
|
||||
lcd.printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5);
|
||||
break;
|
||||
case 3:
|
||||
lcd.printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5);
|
||||
break;
|
||||
case 4:
|
||||
lcd.printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5);
|
||||
break;
|
||||
case 5:
|
||||
lcd.printNumber(xTaskGetTickCount() / 100, 5);
|
||||
break;
|
||||
case 6:
|
||||
lcd.printNumber(lastMovementTime / 100, 5);
|
||||
break;
|
||||
case 7:
|
||||
lcd.printNumber(getTipRawTemp(0),5);
|
||||
break;
|
||||
case 8:
|
||||
lcd.printNumber(tipMeasurementToC(getTipRawTemp(0)),5);
|
||||
break;
|
||||
case 9:
|
||||
printVoltage();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
lcd.refresh();
|
||||
b = getButtonState();
|
||||
if (b == BUTTON_B_SHORT)
|
||||
return;
|
||||
else if (b == BUTTON_F_SHORT) {
|
||||
screen++;
|
||||
screen = screen % 10;
|
||||
}
|
||||
GUIDelay();
|
||||
}
|
||||
}
|
||||
|
||||
/* StartGUITask function */
|
||||
void startGUITask(void const *argument) {
|
||||
/*
|
||||
* Main program states:
|
||||
*
|
||||
* * Soldering (gui_solderingMode)
|
||||
* -> Main loop where we draw temp, and animations
|
||||
* --> User presses buttons and they goto the temperature adjust screen
|
||||
* ---> Display the current setpoint temperature
|
||||
* ---> Use buttons to change forward and back on temperature
|
||||
* ---> Both buttons or timeout for exiting
|
||||
* --> Long hold front button to enter boost mode
|
||||
* ---> Just temporarily sets the system into the alternate temperature for
|
||||
* PID control
|
||||
* --> Long hold back button to exit
|
||||
* --> Double button to exit
|
||||
* * Settings Menu (gui_settingsMenu)
|
||||
* -> Show setting name
|
||||
* --> If no button press for > 3 Seconds, scroll description
|
||||
* -> If user presses back button, adjust the setting
|
||||
* -> Currently the same as 1.x (future to make more depth based)
|
||||
*/
|
||||
|
||||
uint8_t animationStep = 0;
|
||||
i2cDev.FRToSInit();
|
||||
uint8_t tempWarningState = 0;
|
||||
bool buttonLockout = false;
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
switch (systemSettings.OrientationMode) {
|
||||
case 0:
|
||||
lcd.setRotation(false);
|
||||
break;
|
||||
case 1:
|
||||
lcd.setRotation(true);
|
||||
break;
|
||||
case 2:
|
||||
lcd.setRotation(false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
bool tempOnDisplay = false;
|
||||
getTipRawTemp(2); //reset filter
|
||||
lcd.setRotation(systemSettings.OrientationMode & 1);
|
||||
uint32_t ticks = xTaskGetTickCount();
|
||||
ticks += 400; //4 seconds from now
|
||||
while (xTaskGetTickCount() < ticks) {
|
||||
@@ -689,8 +656,6 @@ void startGUITask(void const *argument) {
|
||||
ticks = xTaskGetTickCount(); //make timeout now so we will exit
|
||||
GUIDelay();
|
||||
}
|
||||
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
if (systemSettings.autoStartMode) {
|
||||
// jump directly to the autostart mode
|
||||
if (systemSettings.autoStartMode == 1)
|
||||
@@ -708,12 +673,14 @@ void startGUITask(void const *argument) {
|
||||
|
||||
for (;;) {
|
||||
ButtonState buttons = getButtonState();
|
||||
|
||||
if (tempWarningState == 2)
|
||||
buttons = BUTTON_F_SHORT;
|
||||
if (buttons != BUTTON_NONE && buttonLockout)
|
||||
buttons = BUTTON_NONE;
|
||||
else
|
||||
buttonLockout = false;
|
||||
|
||||
switch (buttons) {
|
||||
case BUTTON_NONE:
|
||||
// Do nothing
|
||||
@@ -725,18 +692,7 @@ void startGUITask(void const *argument) {
|
||||
|
||||
case BUTTON_B_LONG:
|
||||
// Show the version information
|
||||
{
|
||||
lcd.clearScreen(); // Ensure the buffer starts clean
|
||||
lcd.setCursor(0, 0); // Position the cursor at the 0,0 (top left)
|
||||
lcd.setFont(1); // small font
|
||||
lcd.print((char *) "V2.04 PCB"); // Print version number
|
||||
lcd.printNumber(PCBVersion, 1); //Print PCB ID number
|
||||
lcd.setCursor(0, 8); // second line
|
||||
lcd.print(__DATE__); // print the compile date
|
||||
lcd.refresh();
|
||||
waitForButtonPress();
|
||||
lcd.setFont(0); // reset font
|
||||
}
|
||||
showVersion();
|
||||
break;
|
||||
case BUTTON_F_LONG:
|
||||
gui_solderingTempAdjust();
|
||||
@@ -746,7 +702,7 @@ void startGUITask(void const *argument) {
|
||||
lcd.setFont(0);
|
||||
lcd.displayOnOff(true); // turn lcd on
|
||||
gui_solderingMode(); // enter soldering mode
|
||||
tempWarningState = 0; // make sure warning can show
|
||||
buttonLockout = true;
|
||||
break;
|
||||
case BUTTON_B_SHORT:
|
||||
lcd.setFont(0);
|
||||
@@ -762,7 +718,7 @@ void startGUITask(void const *argument) {
|
||||
|
||||
currentlyActiveTemperatureTarget = 0; // ensure tip is off
|
||||
|
||||
uint16_t tipTemp = tipMeasurementToC(getTipRawTemp(1));//This forces a faster update rate on the filtering
|
||||
uint16_t tipTemp = tipMeasurementToC(getTipRawTemp(1)); //This forces a faster update rate on the filtering
|
||||
|
||||
if (tipTemp < 50) {
|
||||
|
||||
@@ -780,17 +736,7 @@ void startGUITask(void const *argument) {
|
||||
|
||||
if (tipTemp > 600)
|
||||
tipTemp = 0;
|
||||
if (tipTemp > 50) {
|
||||
if (tempWarningState == 0) {
|
||||
currentlyActiveTemperatureTarget = 0; // ensure tip is off
|
||||
lcd.displayOnOff(true); // force LCD on
|
||||
if (gui_showTipTempWarning() == 1) {
|
||||
tempWarningState = 2; // we can re-enter the warning
|
||||
} else
|
||||
tempWarningState = 1;
|
||||
}
|
||||
} else
|
||||
tempWarningState = 0;
|
||||
|
||||
// Clear the lcd buffer
|
||||
lcd.clearScreen();
|
||||
lcd.setCursor(0, 0);
|
||||
@@ -809,11 +755,7 @@ void startGUITask(void const *argument) {
|
||||
}
|
||||
lcd.setCursor(0, 8);
|
||||
lcd.print(InputVoltageString);
|
||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
|
||||
2);
|
||||
lcd.drawChar('.');
|
||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
|
||||
1);
|
||||
printVoltage();
|
||||
lcd.print("V");
|
||||
|
||||
} else {
|
||||
@@ -823,14 +765,35 @@ void startGUITask(void const *argument) {
|
||||
lcd.setCursor(0, 0);
|
||||
gui_drawBatteryIcon();
|
||||
} else {
|
||||
lcd.drawArea(0, 0, 84, 16, idleScreenBGF); // Needs to be flipped
|
||||
lcd.drawArea(0, 0, 84, 16, idleScreenBGF); // Needs to be flipped so button ends up on right side of screen
|
||||
lcd.setCursor(84, 0);
|
||||
gui_drawBatteryIcon();
|
||||
}
|
||||
if (tipTemp > 55)
|
||||
tempOnDisplay = true;
|
||||
else if (tipTemp < 45)
|
||||
tempOnDisplay = false;
|
||||
if (tempOnDisplay) {
|
||||
//draw temp over the start soldering button
|
||||
//Location changes on screen rotation
|
||||
if (lcd.getRotation()) {
|
||||
// in right handed mode we want to draw over the first part
|
||||
lcd.fillArea(55, 0, 41, 16, 0); //clear the area for the temp
|
||||
lcd.setCursor(56, 0);
|
||||
|
||||
} else {
|
||||
lcd.fillArea(0, 0, 41, 16, 0); //clear the area
|
||||
lcd.setCursor(0, 0);
|
||||
}
|
||||
//draw in the temp
|
||||
lcd.setFont(0); //big font
|
||||
if (!(systemSettings.coolingTempBlink
|
||||
&& (xTaskGetTickCount() % 50 < 25)))
|
||||
gui_drawTipTemp(false); // draw in the temp
|
||||
}
|
||||
}
|
||||
|
||||
lcd.refresh();
|
||||
animationStep++;
|
||||
GUIDelay();
|
||||
}
|
||||
}
|
||||
@@ -851,111 +814,110 @@ void startPIDTask(void const *argument) {
|
||||
osDelay(500);
|
||||
int32_t integralCount = 0;
|
||||
int32_t derivativeLastValue = 0;
|
||||
int32_t kp, ki, kd;
|
||||
kp = 40;
|
||||
ki = 60;
|
||||
kd = 20;
|
||||
// REMEBER ^^^^ These constants are backwards
|
||||
// They act as dividers, so to 'increase' a P term, you make the number
|
||||
// smaller.
|
||||
if(getInputVoltageX10(systemSettings.voltageDiv) < 150)
|
||||
{
|
||||
//Boot P term if < 15 Volts
|
||||
kp=30;
|
||||
}
|
||||
|
||||
// REMEBER ^^^^ These constants are backwards
|
||||
// They act as dividers, so to 'increase' a P term, you make the number
|
||||
// smaller.
|
||||
|
||||
const int32_t itermMax = 100;
|
||||
pidTaskNotification = xTaskGetCurrentTaskHandle();
|
||||
for (;;) {
|
||||
uint16_t rawTemp = getTipRawTemp(1); // get instantaneous reading
|
||||
if (currentlyActiveTemperatureTarget) {
|
||||
// Compute the PID loop in here
|
||||
// Because our values here are quite large for all measurements (0-16k ~=
|
||||
// 33 counts per C)
|
||||
// P I & D are divisors, so inverse logic applies (beware)
|
||||
if (ulTaskNotifyTake( pdTRUE, 50)) {
|
||||
//Wait a max of 50ms
|
||||
//This is a call to block this thread until the ADC does its samples
|
||||
uint16_t rawTemp = getTipRawTemp(1); // get instantaneous reading
|
||||
if (currentlyActiveTemperatureTarget) {
|
||||
// Compute the PID loop in here
|
||||
// Because our values here are quite large for all measurements (0-16k ~=
|
||||
// 33 counts per C)
|
||||
// P I & D are divisors, so inverse logic applies (beware)
|
||||
|
||||
// Cap the max set point to 450C
|
||||
if (currentlyActiveTemperatureTarget > ctoTipMeasurement(450)) {
|
||||
currentlyActiveTemperatureTarget = ctoTipMeasurement(450);
|
||||
// Cap the max set point to 450C
|
||||
if (currentlyActiveTemperatureTarget > ctoTipMeasurement(450)) {
|
||||
currentlyActiveTemperatureTarget = ctoTipMeasurement(450);
|
||||
}
|
||||
|
||||
int32_t rawTempError = currentlyActiveTemperatureTarget
|
||||
- rawTemp;
|
||||
int32_t ierror = (rawTempError
|
||||
/ ((int32_t) systemSettings.PID_I));
|
||||
integralCount += ierror;
|
||||
if (integralCount > (itermMax / 2))
|
||||
integralCount = itermMax / 2; // prevent too much lead
|
||||
else if (integralCount < -itermMax)
|
||||
integralCount = itermMax;
|
||||
|
||||
int32_t dInput = (rawTemp - derivativeLastValue);
|
||||
|
||||
/*Compute PID Output*/
|
||||
int32_t output = (rawTempError
|
||||
/ ((int32_t) systemSettings.PID_P));
|
||||
if (((int32_t) systemSettings.PID_I))
|
||||
output += integralCount;
|
||||
if (((int32_t) systemSettings.PID_D))
|
||||
output -= (dInput / ((int32_t) systemSettings.PID_D));
|
||||
|
||||
if (output > 100) {
|
||||
output = 100; // saturate
|
||||
} else if (output < 0) {
|
||||
output = 0;
|
||||
}
|
||||
|
||||
/*if (currentlyActiveTemperatureTarget < rawTemp) {
|
||||
output = 0;
|
||||
}*/
|
||||
setTipPWM(output);
|
||||
derivativeLastValue = rawTemp; // store for next loop
|
||||
|
||||
} else {
|
||||
setTipPWM(0); // disable the output driver if the output is set to be off
|
||||
integralCount = 0;
|
||||
derivativeLastValue = 0;
|
||||
}
|
||||
|
||||
int32_t rawTempError = currentlyActiveTemperatureTarget - rawTemp;
|
||||
int32_t ierror = (rawTempError / ki);
|
||||
integralCount += ierror;
|
||||
if (integralCount > (itermMax / 2))
|
||||
integralCount = itermMax / 2; // prevent too much lead
|
||||
else if (integralCount < -itermMax)
|
||||
integralCount = itermMax;
|
||||
|
||||
int32_t dInput = (rawTemp - derivativeLastValue);
|
||||
|
||||
/*Compute PID Output*/
|
||||
int32_t output = (rawTempError / kp);
|
||||
if (ki)
|
||||
output += integralCount;
|
||||
if (kd)
|
||||
output -= (dInput / kd);
|
||||
|
||||
if (output > 100) {
|
||||
output = 100; // saturate
|
||||
} else if (output < 0) {
|
||||
output = 0;
|
||||
}
|
||||
|
||||
if (currentlyActiveTemperatureTarget < rawTemp) {
|
||||
output = 0;
|
||||
}
|
||||
setTipPWM(output);
|
||||
derivativeLastValue = rawTemp; // store for next loop
|
||||
|
||||
} else {
|
||||
setTipPWM(0); // disable the output driver if the output is set to be off
|
||||
integralCount = 0;
|
||||
derivativeLastValue = 0;
|
||||
osDelay(100); //sleep for a bit longer
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
}
|
||||
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
osDelay(10); // 100 Hz temp loop
|
||||
}
|
||||
}
|
||||
#define MOVFilter 8
|
||||
void startMOVTask(void const *argument) {
|
||||
osDelay(4000); // wait for accel to stabilize
|
||||
osDelay(250); // wait for accelerometer to stabilize
|
||||
lcd.setRotation(systemSettings.OrientationMode & 1);
|
||||
lastMovementTime = 0;
|
||||
int16_t datax[MOVFilter];
|
||||
int16_t datay[MOVFilter];
|
||||
int16_t dataz[MOVFilter];
|
||||
int16_t datax[MOVFilter] = { 0 };
|
||||
int16_t datay[MOVFilter] = { 0 };
|
||||
int16_t dataz[MOVFilter] = { 0 };
|
||||
uint8_t currentPointer = 0;
|
||||
memset(datax, 0, MOVFilter * sizeof(int16_t));
|
||||
memset(datay, 0, MOVFilter * sizeof(int16_t));
|
||||
memset(dataz, 0, MOVFilter * sizeof(int16_t));
|
||||
int16_t tx, ty, tz;
|
||||
int32_t avgx, avgy, avgz;
|
||||
int16_t tx = 0, ty = 0, tz = 0;
|
||||
int32_t avgx = 0, avgy = 0, avgz = 0;
|
||||
if (systemSettings.sensitivity > 9)
|
||||
systemSettings.sensitivity = 9;
|
||||
#if ACCELDEBUG
|
||||
uint32_t max = 0;
|
||||
#endif
|
||||
|
||||
if (PCBVersion == 3) {
|
||||
for (;;)
|
||||
osDelay(5000);
|
||||
}
|
||||
Orientation rotation = ORIENTATION_FLAT;
|
||||
for (;;) {
|
||||
int32_t threshold = 1500 + (9 * 200);
|
||||
threshold -= systemSettings.sensitivity * 200; // 200 is the step size
|
||||
if (PCBVersion == 2)
|
||||
accel2.getAxisReadings(&tx, &ty, &tz);
|
||||
else if (PCBVersion == 1)
|
||||
accel.getAxisReadings(&tx, &ty, &tz);
|
||||
|
||||
if (PCBVersion == 2) {
|
||||
accel2.getAxisReadings(&tx, &ty, &tz);
|
||||
rotation = accel2.getOrientation();
|
||||
} else if (PCBVersion == 1) {
|
||||
accel.getAxisReadings(&tx, &ty, &tz);
|
||||
rotation = accel.getOrientation();
|
||||
}
|
||||
if (systemSettings.OrientationMode == 2) {
|
||||
if (rotation != ORIENTATION_FLAT) {
|
||||
lcd.setRotation(rotation == ORIENTATION_LEFT_HAND); // link the data through
|
||||
}
|
||||
}
|
||||
datax[currentPointer] = (int32_t) tx;
|
||||
datay[currentPointer] = (int32_t) ty;
|
||||
dataz[currentPointer] = (int32_t) tz;
|
||||
currentPointer = (currentPointer + 1) % MOVFilter;
|
||||
#if ACCELDEBUG
|
||||
// Debug for Accel
|
||||
|
||||
avgx = avgy = avgz = 0;
|
||||
// calculate averages
|
||||
for (uint8_t i = 0; i < MOVFilter; i++) {
|
||||
avgx += datax[i];
|
||||
avgy += datay[i];
|
||||
@@ -964,37 +926,35 @@ void startMOVTask(void const *argument) {
|
||||
avgx /= MOVFilter;
|
||||
avgy /= MOVFilter;
|
||||
avgz /= MOVFilter;
|
||||
|
||||
//Sum the deltas
|
||||
int32_t error = (abs(avgx - tx) + abs(avgy - ty) + abs(avgz - tz));
|
||||
|
||||
#if ACCELDEBUG
|
||||
// Debug for Accel
|
||||
|
||||
lcd.setFont(1);
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.printNumber(abs(avgx - (int32_t) tx), 5);
|
||||
lcd.print(" ");
|
||||
lcd.printNumber(abs(avgy - (int32_t) ty), 5);
|
||||
if ((abs(avgx - tx) + abs(avgy - ty) + abs(avgz - tz)) > max)
|
||||
max = (abs(avgx - tx) + abs(avgy - ty) + abs(avgz - tz));
|
||||
if (error > max) {
|
||||
max = (abs(avgx - tx) + abs(avgy - ty) + abs(avgz - tz));
|
||||
}
|
||||
lcd.setCursor(0, 8);
|
||||
lcd.printNumber(max, 5);
|
||||
lcd.print(" ");
|
||||
|
||||
lcd.printNumber((abs(avgx - tx) + abs(avgy - ty) + abs(avgz - tz)), 5);
|
||||
lcd.refresh();
|
||||
if (HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET)
|
||||
max = 0;
|
||||
#endif
|
||||
|
||||
// calculate averages
|
||||
avgx = avgy = avgz = 0;
|
||||
for (uint8_t i = 0; i < MOVFilter; i++) {
|
||||
avgx += datax[i];
|
||||
avgy += datay[i];
|
||||
avgz += dataz[i];
|
||||
if (HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET) {
|
||||
max = 0;
|
||||
}
|
||||
avgx /= MOVFilter;
|
||||
avgy /= MOVFilter;
|
||||
avgz /= MOVFilter;
|
||||
#endif
|
||||
|
||||
// So now we have averages, we want to look if these are different by more
|
||||
// than the threshold
|
||||
int32_t error = (abs(avgx - tx) + abs(avgy - ty) + abs(avgz - tz));
|
||||
|
||||
// If error has occurred then we update the tick timer
|
||||
if (error > threshold) {
|
||||
lastMovementTime = xTaskGetTickCount();
|
||||
@@ -1003,56 +963,14 @@ void startMOVTask(void const *argument) {
|
||||
osDelay(100); // Slow down update rate
|
||||
}
|
||||
}
|
||||
/* StartRotationTask function */
|
||||
void startRotationTask(void const *argument) {
|
||||
/*
|
||||
* This task is used to manage rotation of the LCD screen & button re-mapping
|
||||
*
|
||||
*/
|
||||
if (PCBVersion == 3) {
|
||||
for (;;)
|
||||
osDelay(5000);
|
||||
}
|
||||
switch (systemSettings.OrientationMode) {
|
||||
case 0:
|
||||
lcd.setRotation(false);
|
||||
break;
|
||||
case 1:
|
||||
lcd.setRotation(true);
|
||||
break;
|
||||
case 2:
|
||||
lcd.setRotation(false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
osDelay(500); // wait for accel to stabilize
|
||||
|
||||
for (;;) {
|
||||
|
||||
// a rotation event has occurred
|
||||
uint8_t rotation = 0;
|
||||
if (PCBVersion == 2) {
|
||||
rotation = accel2.getOrientation();
|
||||
} else if (PCBVersion == 1) {
|
||||
rotation = accel.getOrientation();
|
||||
}
|
||||
if (systemSettings.OrientationMode == 2) {
|
||||
if (rotation != 0) {
|
||||
lcd.setRotation(rotation == 2); // link the data through
|
||||
}
|
||||
}
|
||||
|
||||
osDelay(500);
|
||||
}
|
||||
}
|
||||
|
||||
#define FLASH_LOGOADDR \
|
||||
(0x8000000 | 0xF800) /*second last page of flash set aside for logo image*/
|
||||
|
||||
bool showBootLogoIfavailable() {
|
||||
// check if the header is there (0xAA,0x55,0xF0,0x0D)
|
||||
// If so display logo
|
||||
// check if the header is there (0xAA,0x55,0xF0,0x0D)
|
||||
// If so display logo
|
||||
//TODO REDUCE STACK ON THIS ONE, USE DRAWING IN THE READ LOOP
|
||||
uint16_t temp[98];
|
||||
|
||||
for (uint8_t i = 0; i < (98); i++) {
|
||||
@@ -1077,3 +995,43 @@ bool showBootLogoIfavailable() {
|
||||
lcd.refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc) {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
if (pidTaskNotification) {
|
||||
/* Notify the task that the transmission is complete. */
|
||||
vTaskNotifyGiveFromISR(pidTaskNotification, &xHigherPriorityTaskWoken);
|
||||
|
||||
/* If xHigherPriorityTaskWoken is now set to pdTRUE then a context switch
|
||||
should be performed to ensure the interrupt returns directly to the highest
|
||||
priority task. The macro used for this purpose is dependent on the port in
|
||||
use and may be called portEND_SWITCHING_ISR(). */
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void vApplicationStackOverflowHook( xTaskHandle *pxTask,
|
||||
signed portCHAR *pcTaskName) {
|
||||
//We dont have a good way to handle a stack overflow at this point in time
|
||||
NVIC_SystemReset();
|
||||
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ void HAL_MspInit(void) {
|
||||
|
||||
/**NOJTAG: JTAG-DP Disabled and SW-DP Enabled
|
||||
*/
|
||||
__HAL_AFIO_REMAP_SWJ_NOJTAG();
|
||||
// __HAL_AFIO_REMAP_SWJ_DISABLE(); /*Disable swd for debug io use*/
|
||||
|
||||
//__HAL_AFIO_REMAP_SWJ_NOJTAG()
|
||||
//;
|
||||
__HAL_AFIO_REMAP_SWJ_DISABLE(); /*Disable swd for debug io use*/
|
||||
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) {
|
||||
__HAL_LINKDMA(hadc, DMA_Handle, hdma_adc1);
|
||||
|
||||
/* ADC1 interrupt Init */
|
||||
HAL_NVIC_SetPriority(ADC1_2_IRQn, 5, 0);
|
||||
HAL_NVIC_SetPriority(ADC1_2_IRQn, 15, 0);
|
||||
HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
|
||||
}
|
||||
|
||||
@@ -77,22 +77,51 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) {
|
||||
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) {
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
if (hi2c->Instance == I2C1) {
|
||||
/**I2C1 GPIO Configuration
|
||||
PB6 ------> I2C1_SCL
|
||||
PB7 ------> I2C1_SDA
|
||||
*/
|
||||
GPIO_InitStruct.Pin = SCL_Pin | SDA_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
/**I2C1 GPIO Configuration
|
||||
PB6 ------> I2C1_SCL
|
||||
PB7 ------> I2C1_SDA
|
||||
*/
|
||||
GPIO_InitStruct.Pin = SCL_Pin | SDA_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_I2C1_CLK_ENABLE()
|
||||
;
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_I2C1_CLK_ENABLE()
|
||||
;
|
||||
/* I2C1 DMA Init */
|
||||
/* I2C1_RX Init */
|
||||
hdma_i2c1_rx.Instance = DMA1_Channel7;
|
||||
hdma_i2c1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_i2c1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_i2c1_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_i2c1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_i2c1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_i2c1_rx.Init.Mode = DMA_NORMAL;
|
||||
hdma_i2c1_rx.Init.Priority = DMA_PRIORITY_MEDIUM;
|
||||
HAL_DMA_Init(&hdma_i2c1_rx);
|
||||
|
||||
}
|
||||
__HAL_LINKDMA(hi2c, hdmarx, hdma_i2c1_rx);
|
||||
|
||||
/* I2C1_TX Init */
|
||||
hdma_i2c1_tx.Instance = DMA1_Channel6;
|
||||
hdma_i2c1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||
hdma_i2c1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_i2c1_tx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_i2c1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_i2c1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_i2c1_tx.Init.Mode = DMA_NORMAL;
|
||||
hdma_i2c1_tx.Init.Priority = DMA_PRIORITY_MEDIUM;
|
||||
HAL_DMA_Init(&hdma_i2c1_tx);
|
||||
|
||||
__HAL_LINKDMA(hi2c, hdmatx, hdma_i2c1_tx);
|
||||
|
||||
/* I2C1 interrupt Init */
|
||||
HAL_NVIC_SetPriority(I2C1_EV_IRQn, 15, 0);
|
||||
HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
|
||||
HAL_NVIC_SetPriority(I2C1_ER_IRQn, 15, 0);
|
||||
HAL_NVIC_EnableIRQ(I2C1_ER_IRQn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ void SysTick_Handler(void) {
|
||||
void DMA1_Channel1_IRQHandler(void) {
|
||||
HAL_DMA_IRQHandler(&hdma_adc1);
|
||||
}
|
||||
|
||||
//ADC interrupt used for DMA
|
||||
void ADC1_2_IRQHandler(void) {
|
||||
HAL_ADC_IRQHandler(&hadc1);
|
||||
@@ -63,7 +62,6 @@ void ADC1_2_IRQHandler(void) {
|
||||
//Timer 1 has overflowed, used for HAL ticks
|
||||
void TIM1_UP_IRQHandler(void) {
|
||||
HAL_TIM_IRQHandler(&htim1);
|
||||
|
||||
}
|
||||
//Timer 3 is used for the PWM output to the tip
|
||||
void TIM3_IRQHandler(void) {
|
||||
@@ -74,13 +72,18 @@ void TIM3_IRQHandler(void) {
|
||||
void TIM2_IRQHandler(void) {
|
||||
HAL_TIM_IRQHandler(&htim2);
|
||||
}
|
||||
//EXTI 3 is triggered via the accelerometer on orientation change
|
||||
void EXTI3_IRQHandler(void) {
|
||||
|
||||
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3);
|
||||
void I2C1_EV_IRQHandler(void) {
|
||||
HAL_I2C_EV_IRQHandler(&hi2c1);
|
||||
}
|
||||
void I2C1_ER_IRQHandler(void) {
|
||||
HAL_I2C_ER_IRQHandler(&hi2c1);
|
||||
}
|
||||
//EXTI 5 is triggered via the accelerometer on movement
|
||||
void EXTI9_5_IRQHandler(void) {
|
||||
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5);
|
||||
|
||||
void DMA1_Channel6_IRQHandler(void) {
|
||||
HAL_DMA_IRQHandler(&hdma_i2c1_tx);
|
||||
}
|
||||
|
||||
void DMA1_Channel7_IRQHandler(void) {
|
||||
HAL_DMA_IRQHandler(&hdma_i2c1_rx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user