settings_screen.c 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654
  1. /*
  2. * debug_screen.c
  3. *
  4. * Created on: Jan 12, 2021
  5. * Author: David Original work by Jose (PTDreamer), 2017
  6. */
  7. #include "settings_screen.h"
  8. #include "main_screen.h"
  9. #include "debug_screen.h"
  10. #include "oled.h"
  11. #include "gui.h"
  12. #include "board.h"
  13. #include "settings.h"
  14. //-------------------------------------------------------------------------------------------------------------------------------
  15. // Settings screen variables
  16. //-------------------------------------------------------------------------------------------------------------------------------
  17. static char t[TipSize][TipCharSize];
  18. static int32_t temp, settingsTimer;
  19. static uint8_t resStatus, profile, Selected_Tip, Tip_name_return;
  20. static char str[5];
  21. static tipData tipCfg;
  22. //-------------------------------------------------------------------------------------------------------------------------------
  23. // Settings screen widgets
  24. //-------------------------------------------------------------------------------------------------------------------------------
  25. screen_t Screen_settingsmenu;
  26. screen_t Screen_iron;
  27. screen_t Screen_system;
  28. screen_t Screen_reset;
  29. screen_t Screen_reset_confirmation;
  30. screen_t Screen_edit_iron_tips;
  31. screen_t Screen_edit_tip_name;
  32. screen_t Screen_edit_tip_settings;
  33. // SETTINGS SCREEM
  34. static widget_t comboWidget_Settings;
  35. static comboBox_widget_t comboBox_Settings;
  36. static comboBox_item_t Settings_Combo_IRON;
  37. static comboBox_item_t Settings_Combo_SYSTEM;
  38. static comboBox_item_t Settings_Combo_TIPS;
  39. static comboBox_item_t Settings_Combo_CALIBRATION;
  40. #ifdef ENABLE_DEBUG_SCREEN
  41. static comboBox_item_t Settings_Combo_DEBUG;
  42. #endif
  43. static comboBox_item_t Settings_Combo_EXIT;
  44. // SYSTEM
  45. static widget_t comboWidget_SYSTEM;
  46. static comboBox_widget_t comboBox_SYSTEM;
  47. static comboBox_item_t comboitem_SYSTEM_Profile;
  48. static comboBox_item_t comboitem_SYSTEM_Contrast;
  49. static comboBox_item_t comboitem_SYSTEM_OledDimming;
  50. static comboBox_item_t comboitem_SYSTEM_OledOffset;
  51. static comboBox_item_t comboitem_SYSTEM_WakeMode;
  52. static comboBox_item_t comboitem_SYSTEM_StandMode;
  53. static comboBox_item_t comboitem_SYSTEM_EncoderMode;
  54. static comboBox_item_t comboitem_SYSTEM_TempUnit;
  55. static comboBox_item_t comboitem_SYSTEM_TempStep;
  56. static comboBox_item_t comboitem_SYSTEM_GuiUpd;
  57. static comboBox_item_t comboitem_SYSTEM_SaveInterval;
  58. static comboBox_item_t comboitem_SYSTEM_Buzzer;
  59. static comboBox_item_t comboitem_SYSTEM_LVP;
  60. static comboBox_item_t comboitem_SYSTEM_InitMode;
  61. static comboBox_item_t comboitem_SYSTEM_ButtonWake;
  62. static comboBox_item_t comboitem_SYSTEM_ShakeWake;
  63. static comboBox_item_t comboitem_SYSTEM_ActiveDetection;
  64. static comboBox_item_t comboitem_SYSTEM_Reset;
  65. static comboBox_item_t comboitem_SYSTEM_SW;
  66. static comboBox_item_t comboitem_SYSTEM_HW;
  67. static comboBox_item_t comboitem_SYSTEM_Back;
  68. static editable_widget_t editable_SYSTEM_Profile;
  69. static editable_widget_t editable_SYSTEM_Contrast;
  70. static editable_widget_t editable_SYSTEM_OledDimming;
  71. static editable_widget_t editable_SYSTEM_OledOffset;
  72. static editable_widget_t editable_SYSTEM_WakeMode;
  73. static editable_widget_t editable_SYSTEM_StandMode;
  74. static editable_widget_t editable_SYSTEM_EncoderMode;
  75. static editable_widget_t editable_SYSTEM_TempUnit;
  76. static editable_widget_t editable_SYSTEM_TempStep;
  77. static editable_widget_t editable_SYSTEM_GuiUpd;
  78. static editable_widget_t editable_SYSTEM_SaveInterval;
  79. static editable_widget_t editable_SYSTEM_Buzzer;
  80. static editable_widget_t editable_SYSTEM_LVP;
  81. static editable_widget_t editable_SYSTEM_InitMode;
  82. static editable_widget_t editable_SYSTEM_ButtonWake;
  83. static editable_widget_t editable_SYSTEM_ShakeWake;
  84. static editable_widget_t editable_SYSTEM_ActiveDetection;
  85. // IRON SETTINGS
  86. static widget_t comboWidget_IRON;
  87. static comboBox_widget_t comboBox_IRON;
  88. static comboBox_item_t comboitem_IRON_SleepTime;
  89. static comboBox_item_t comboitem_IRON_StandbyTime;
  90. static comboBox_item_t comboitem_IRON_StandbyTemp;
  91. #ifdef USE_VIN
  92. static comboBox_item_t comboitem_IRON_Power;
  93. static comboBox_item_t comboitem_IRON_Impedance;
  94. #endif
  95. static comboBox_item_t comboitem_IRON_MaxTemp;
  96. static comboBox_item_t comboitem_IRON_MinTemp;
  97. static comboBox_item_t comboitem_IRON_PWMPeriod;
  98. static comboBox_item_t comboitem_IRON_ADCDelay;
  99. static comboBox_item_t comboitem_IRON_filterFactor;
  100. static comboBox_item_t comboitem_IRON_errorDelay;
  101. static comboBox_item_t comboitem_IRON_ADCLimit;
  102. static comboBox_item_t comboitem_IRON_Back;
  103. static editable_widget_t editable_IRON_SleepTime;
  104. static editable_widget_t editable_IRON_StandbyTime;
  105. static editable_widget_t editable_IRON_StandbyTemp;
  106. #ifdef USE_VIN
  107. static editable_widget_t editable_IRON_Power;
  108. static editable_widget_t editable_IRON_Impedance;
  109. #endif
  110. static editable_widget_t editable_IRON_MaxTemp;
  111. static editable_widget_t editable_IRON_MinTemp;
  112. static editable_widget_t editable_IRON_ADCLimit;
  113. static editable_widget_t editable_IRON_PWMPeriod;
  114. static editable_widget_t editable_IRON_ADCDelay;
  115. static editable_widget_t editable_IRON_filterFactor;
  116. static editable_widget_t editable_IRON_errorDelay;
  117. // EDIT TIPS SCREEN
  118. static widget_t comboWidget_IRONTIPS;
  119. static comboBox_widget_t comboBox_IRONTIPS;
  120. static comboBox_item_t comboitem_IRONTIPS[TipSize];
  121. static comboBox_item_t comboitem_IRONTIPS_addNewTip;
  122. static comboBox_item_t comboitem_IRONTIPS_Back;
  123. // EDIT TIP NAME SCREEN
  124. static widget_t Widget_IRONTIPS_Name_Back;
  125. static button_widget_t button_IRONTIPS_Name_Back;
  126. static widget_t Widget_IRONTIPS_Name_Save;
  127. static button_widget_t button_IRONTIPS_Name_Save;
  128. static widget_t Widget_IRONTIPS_Name_Delete;
  129. static button_widget_t button_IRONTIPS_Name_Delete;
  130. static widget_t Widget_IRONTIPS_Name_Edit;
  131. static editable_widget_t editable_IRONTIPS_Name_Edit;
  132. // EDIT TIP SETTINGS SCREEN
  133. static widget_t comboWidget_IRONTIPS_Settings;
  134. static comboBox_widget_t comboBox_IRONTIPS_Settings;
  135. static comboBox_item_t comboitem_IRONTIPS_Settings_TipLabel;
  136. static comboBox_item_t comboitem_IRONTIPS_Settings_PID_KP;
  137. static comboBox_item_t comboitem_IRONTIPS_Settings_PID_KI;
  138. static comboBox_item_t comboitem_IRONTIPS_Settings_PID_KD;
  139. static comboBox_item_t comboitem_IRONTIPS_Settings_PID_Imax;
  140. static comboBox_item_t comboitem_IRONTIPS_Settings_PID_Imin;
  141. static comboBox_item_t comboitem_IRONTIPS_Settings_Cal250;
  142. static comboBox_item_t comboitem_IRONTIPS_Settings_Cal350;
  143. static comboBox_item_t comboitem_IRONTIPS_Settings_Cal450;
  144. static editable_widget_t editable_IRONTIPS_Settings_PID_Kd;
  145. static editable_widget_t editable_IRONTIPS_Settings_PID_Ki;
  146. static editable_widget_t editable_IRONTIPS_Settings_PID_Kp;
  147. static editable_widget_t editable_IRONTIPS_Settings_PID_Imax;
  148. static editable_widget_t editable_IRONTIPS_Settings_PID_Imin;
  149. static editable_widget_t editable_IRONTIPS_Settings_Cal250;
  150. static editable_widget_t editable_IRONTIPS_Settings_Cal350;
  151. static editable_widget_t editable_IRONTIPS_Settings_Cal450;
  152. static comboBox_item_t comboitem_IRONTIPS_Settings_Save;
  153. static comboBox_item_t comboitem_IRONTIPS_Settings_Cancel;
  154. // RESET SCREEN
  155. static widget_t comboWidget_RESET;
  156. static comboBox_widget_t comboBox_RESET;
  157. static comboBox_item_t comboitem_RESET_SETTINGS;
  158. static comboBox_item_t comboitem_RESET_TIP;
  159. static comboBox_item_t comboitem_RESET_ALLTIP;
  160. static comboBox_item_t comboitem_RESET_EVERYTHING;
  161. static comboBox_item_t comboitem_RESET_Back;
  162. static widget_t Widget_Reset_OK;
  163. static button_widget_t button_Reset_OK;
  164. static widget_t Widget_Reset_CANCEL;
  165. static button_widget_t button_Reset_CANCEL;
  166. //-------------------------------------------------------------------------------------------------------------------------------
  167. // Settings screen widgets functions
  168. //-------------------------------------------------------------------------------------------------------------------------------
  169. static void setSettingsScrTempUnit() {
  170. if(systemSettings.settings.tempUnit==mode_Farenheit){
  171. editable_SYSTEM_TempStep.inputData.endString="\260F";
  172. editable_IRON_MaxTemp.inputData.endString="\260F";
  173. editable_IRON_MinTemp.inputData.endString="\260F";
  174. editable_IRON_StandbyTemp.inputData.endString="\260F";
  175. }
  176. else{
  177. editable_SYSTEM_TempStep.inputData.endString="\260C";
  178. editable_IRON_MaxTemp.inputData.endString="\260C";
  179. editable_IRON_MinTemp.inputData.endString="\260C";
  180. editable_IRON_StandbyTemp.inputData.endString="\260C";
  181. }
  182. }
  183. static void *getTipStr() {
  184. return str;
  185. }
  186. static void setTipStr(char *s) {
  187. strcpy(str, s);
  188. }
  189. static int saveTip(widget_t *w) {
  190. if(comboBox_IRONTIPS.currentItem == &comboitem_IRONTIPS_addNewTip) { // If coming from Add New tip option
  191. for(uint8_t x=0;x<TipSize;x++){ // Find first valid tip
  192. if(strcmp(systemSettings.Profile.tip[x].name, " ")!=0){
  193. systemSettings.Profile.tip[systemSettings.Profile.currentNumberOfTips] = systemSettings.Profile.tip[x]; // Copy Tip data (calibration, PID) to new tip
  194. break;
  195. }
  196. }
  197. strcpy(systemSettings.Profile.tip[systemSettings.Profile.currentNumberOfTips++].name, str); // Store new tip name and increase system tip count
  198. }
  199. else {
  200. strcpy(tipCfg.name, str); // If existing tip, store the new name
  201. }
  202. return Tip_name_return; // Return to the screen we came from
  203. }
  204. static int cancelTip(widget_t *w) {
  205. return Tip_name_return; // Return to the screen we came from
  206. }
  207. static int delTip(widget_t *w) {
  208. char str[TipCharSize];
  209. for(uint8_t x=0;x<TipCharSize;x++){
  210. str[x] = ' ';
  211. }
  212. str[TipCharSize-1] = 0;
  213. systemSettings.Profile.currentNumberOfTips--; // Decrease the number of tips in the system
  214. for(int x = Selected_Tip; x < TipSize-1;x++) { // Overwrite selected tip and move the rest one position backwards
  215. systemSettings.Profile.tip[x] = systemSettings.Profile.tip[x+1];
  216. }
  217. for(int x = systemSettings.Profile.currentNumberOfTips; x < TipSize;x++) { // Fill the unused tips with blank names
  218. strcpy(systemSettings.Profile.tip[x].name, str);
  219. }
  220. if(systemSettings.Profile.currentTip >= systemSettings.Profile.currentNumberOfTips){ // Check the system tip is not pointing to a blank slot
  221. systemSettings.Profile.currentTip = systemSettings.Profile.currentNumberOfTips-1; // Select the previous tip in the list if so
  222. }
  223. // Skip tip settings (As tip is now deleted)
  224. return comboitem_IRONTIPS_Settings_Cancel.action_screen; // And return to main screen or system menu screen
  225. }
  226. #ifdef USE_VIN
  227. static void * getMaxPower() {
  228. temp = systemSettings.Profile.power;
  229. return &temp;
  230. }
  231. static void setMaxPower(uint32_t *val) {
  232. systemSettings.Profile.power = *val;
  233. }
  234. static void * getTipImpedance() {
  235. temp = systemSettings.Profile.impedance;
  236. return &temp;
  237. }
  238. static void setTipImpedance(uint32_t *val) {
  239. systemSettings.Profile.impedance = *val;
  240. }
  241. #endif
  242. static void setSleepTime(uint32_t *val) {
  243. systemSettings.Profile.sleepTimeout= *val;
  244. }
  245. static void * getSleepTime() {
  246. temp = systemSettings.Profile.sleepTimeout;
  247. return &temp;
  248. }
  249. static void setStandbyTime(uint32_t *val) {
  250. systemSettings.Profile.standbyTimeout= *val;
  251. }
  252. static void * getStandbyTime() {
  253. temp = systemSettings.Profile.standbyTimeout;
  254. return &temp;
  255. }
  256. static void setStandbyTemp(uint32_t *val) {
  257. systemSettings.Profile.standbyTemperature= *val;
  258. }
  259. static void * getStandbyTemp() {
  260. temp = systemSettings.Profile.standbyTemperature;
  261. return &temp;
  262. }
  263. static void * getKp() {
  264. temp = tipCfg.PID.Kp;
  265. return &temp;
  266. }
  267. static void setKp(int32_t *val) {
  268. tipCfg.PID.Kp = *val;
  269. }
  270. static void * getKi() {
  271. temp = tipCfg.PID.Ki;
  272. return &temp;
  273. }
  274. static void setKi(int32_t *val) {
  275. tipCfg.PID.Ki = *val;
  276. }
  277. static void * getKd() {
  278. temp = tipCfg.PID.Kd;
  279. return &temp;
  280. }
  281. static void setKd(int32_t *val) {
  282. tipCfg.PID.Kd = *val;
  283. }
  284. static void * getImax() {
  285. temp = tipCfg.PID.maxI;
  286. return &temp;
  287. }
  288. static void setImax(int32_t *val) {
  289. tipCfg.PID.maxI = *val;
  290. }
  291. static void * getImin() {
  292. temp = tipCfg.PID.minI;
  293. return &temp;
  294. }
  295. static void setImin(int32_t *val) {
  296. tipCfg.PID.minI= *val;
  297. }
  298. static void * getCal250() {
  299. temp = tipCfg.calADC_At_250;
  300. return &temp;
  301. }
  302. static void setCal250(int32_t *val) {
  303. tipCfg.calADC_At_250 = *val;
  304. }
  305. static void * getCal350() {
  306. temp = tipCfg.calADC_At_350;
  307. editable_IRONTIPS_Settings_Cal350.min_value = tipCfg.calADC_At_250 + 1;
  308. editable_IRONTIPS_Settings_Cal350.max_value = tipCfg.calADC_At_450 - 1;
  309. return &temp;
  310. }
  311. static void setCal350(int32_t *val) {
  312. tipCfg.calADC_At_350 = *val;
  313. }
  314. static void * getCal450() {
  315. temp = tipCfg.calADC_At_450;
  316. editable_IRONTIPS_Settings_Cal450.min_value = tipCfg.calADC_At_350 + 1;
  317. return &temp;
  318. }
  319. static void setCal450(int32_t *val) {
  320. tipCfg.calADC_At_450 = *val;
  321. }
  322. static int IRONTIPS_Save(widget_t *w) {
  323. __disable_irq();
  324. systemSettings.Profile.tip[Selected_Tip] = tipCfg;
  325. if(Selected_Tip==systemSettings.Profile.currentTip){
  326. setupPID(&tipCfg.PID);
  327. resetPID();
  328. }
  329. __enable_irq();
  330. return comboitem_IRONTIPS_Settings_Cancel.action_screen;
  331. }
  332. static void * getPWMPeriod() {
  333. temp=(systemSettings.Profile.pwmPeriod+1)/100;
  334. return &temp;
  335. }
  336. static void setPWMPeriod(uint32_t *val) {
  337. uint16_t period=(*val*100)-1;
  338. if(period>systemSettings.Profile.pwmDelay+(ADC_MEASURE_TIME/10)){
  339. setPwmPeriod(period);
  340. }
  341. else{
  342. uint16_t t=(systemSettings.Profile.pwmDelay+((ADC_MEASURE_TIME/10)+1));
  343. setPwmPeriod(t);
  344. }
  345. }
  346. static void * getPWMDelay() {
  347. temp=(systemSettings.Profile.pwmDelay+1)/10;
  348. return &temp;
  349. }
  350. static void setPWMDelay(uint32_t *val) {
  351. uint16_t delay=(*val*10)-1;
  352. if(delay<(systemSettings.Profile.pwmPeriod-(ADC_MEASURE_TIME/10))){
  353. setPwmDelay(delay);
  354. }
  355. else{
  356. setPwmDelay(systemSettings.Profile.pwmPeriod-((ADC_MEASURE_TIME/10)+1));
  357. }
  358. }
  359. static void * getMaxTemp() {
  360. temp=systemSettings.Profile.MaxSetTemperature;
  361. editable_IRON_MinTemp.max_value = temp-1;
  362. editable_IRON_MaxTemp.min_value = systemSettings.Profile.MinSetTemperature+1;
  363. return &temp;
  364. }
  365. static void setMaxTemp(uint32_t *val) {
  366. systemSettings.Profile.MaxSetTemperature=*val;
  367. }
  368. static void * getMinTemp() {
  369. temp=systemSettings.Profile.MinSetTemperature;
  370. editable_IRON_MaxTemp.min_value = temp+1;
  371. editable_IRON_MinTemp.max_value = systemSettings.Profile.MaxSetTemperature-1;
  372. return &temp;
  373. }
  374. static void setMinTemp(uint32_t *val) {
  375. systemSettings.Profile.MinSetTemperature=*val;
  376. }
  377. static void * getTmpUnit() {
  378. temp = systemSettings.settings.tempUnit;
  379. return &temp;
  380. }
  381. static void setTmpUnit(uint32_t *val) {
  382. setSystemTempUnit(*val);
  383. setSettingsScrTempUnit();
  384. }
  385. static void * getTmpStep() {
  386. temp = systemSettings.settings.tempStep;
  387. return &temp;
  388. }
  389. static void setTmpStep(uint32_t *val) {
  390. systemSettings.settings.tempStep = *val;
  391. }
  392. static void * getContrast_() {
  393. temp = systemSettings.settings.contrast;
  394. return &temp;
  395. }
  396. static void setContrast_(uint32_t *val) {
  397. systemSettings.settings.contrast=*val;
  398. setContrast(*val);
  399. }
  400. static void * getOledOffset() {
  401. temp = systemSettings.settings.OledOffset;
  402. return &temp;
  403. }
  404. static void setOledOffset(uint32_t *val) {
  405. systemSettings.settings.OledOffset= * val;
  406. }
  407. static void * getOledDimming() {
  408. temp = systemSettings.settings.screenDimming;
  409. return &temp;
  410. }
  411. static void setOledDimming(uint32_t *val) {
  412. systemSettings.settings.screenDimming = * val;
  413. }
  414. static void * getActiveDetection() {
  415. temp = systemSettings.settings.activeDetection;
  416. return &temp;
  417. }
  418. static void setActiveDetection(uint32_t *val) {
  419. systemSettings.settings.activeDetection = * val;
  420. }
  421. static void * getWakeMode() {
  422. temp = systemSettings.settings.WakeInputMode;
  423. comboitem_SYSTEM_ButtonWake.enabled = !systemSettings.settings.WakeInputMode; // 0=shake, 1=stand
  424. comboitem_SYSTEM_ShakeWake.enabled = !systemSettings.settings.WakeInputMode;
  425. comboitem_SYSTEM_InitMode.enabled = !systemSettings.settings.WakeInputMode;
  426. comboitem_SYSTEM_StandMode.enabled = systemSettings.settings.WakeInputMode;
  427. return &temp;
  428. }
  429. static void setWakeMode(uint32_t *val) {
  430. systemSettings.settings.WakeInputMode = *val;
  431. }
  432. static void * getStandMode() {
  433. temp = systemSettings.settings.StandMode;
  434. return &temp;
  435. }
  436. static void setStandMode(uint32_t *val) {
  437. systemSettings.settings.StandMode = *val;
  438. }
  439. static void * getEncoderMode() {
  440. temp = systemSettings.settings.EncoderMode;
  441. RE_SetMode(&RE1_Data, systemSettings.settings.EncoderMode);
  442. return &temp;
  443. }
  444. static void setEncoderMode(uint32_t *val) {
  445. systemSettings.settings.EncoderMode = * val;
  446. }
  447. static void * getGuiUpd_ms() {
  448. temp = systemSettings.settings.guiUpdateDelay;
  449. return &temp;
  450. }
  451. static void setGuiUpd_ms(uint32_t *val) {
  452. systemSettings.settings.guiUpdateDelay = *val;
  453. }
  454. static void * getSavDelay() {
  455. temp =systemSettings.settings.saveSettingsDelay;
  456. return &temp;
  457. }
  458. static void setSavDelay(uint32_t *val) {
  459. systemSettings.settings.saveSettingsDelay = *val;
  460. }
  461. static void * getLVP() {
  462. temp = systemSettings.settings.lvp;
  463. return &temp;
  464. }
  465. static void setLVP(uint32_t *val) {
  466. systemSettings.settings.lvp = *val;
  467. }
  468. static void * geterrorDelay() {
  469. temp = systemSettings.settings.errorDelay;
  470. return &temp;
  471. }
  472. static void seterrorDelay(uint32_t *val) {
  473. systemSettings.settings.errorDelay = *val;
  474. }
  475. static void * getNoIronADC() {
  476. temp = systemSettings.Profile.noIronValue;
  477. return &temp;
  478. }
  479. static void setNoIronADC(uint32_t *val) {
  480. systemSettings.Profile.noIronValue = *val;
  481. }
  482. static void * getbuzzerMode() {
  483. temp = systemSettings.settings.buzzerMode;
  484. return &temp;
  485. }
  486. static void setbuzzerMode(uint32_t *val) {
  487. systemSettings.settings.buzzerMode = *val;
  488. }
  489. static void * getInitMode() {
  490. temp = systemSettings.settings.initMode;
  491. return &temp;
  492. }
  493. static void setInitMode(uint32_t *val) {
  494. systemSettings.settings.initMode = *val;
  495. }
  496. static void * getfilterFactor() {
  497. temp = systemSettings.Profile.filterFactor;
  498. return &temp;
  499. }
  500. static void setfilterFactor(uint32_t *val) {
  501. systemSettings.Profile.filterFactor = *val;
  502. }
  503. static void * getProfile() {
  504. temp = profile;
  505. return &temp;
  506. }
  507. static void setProfile(uint32_t *val) {
  508. profile=*val;
  509. }
  510. static int cancelReset(widget_t *w) {
  511. return screen_reset;
  512. }
  513. static int doReset(widget_t *w) {
  514. switch(resStatus){
  515. case 0: // Reset system settings
  516. {
  517. uint8_t currentProfile=systemSettings.settings.currentProfile; // Store current profile
  518. resetSystemSettings(); // Reset system settings
  519. systemSettings.settings.currentProfile=currentProfile; // Restore profile
  520. saveSettings(saveKeepingProfiles); // Save settings preserving tip data
  521. NVIC_SystemReset();
  522. break;
  523. }
  524. case 1: // Reset current profile
  525. resetCurrentProfile(); // Set current profile to defaults
  526. saveSettings(saveKeepingProfiles); // Save settings preserving tip data
  527. NVIC_SystemReset();
  528. break;
  529. case 2: // Reset all Profiles
  530. systemSettings.settings.currentProfile=profile_None; // Set factory value
  531. saveSettings(saveWipingProfiles); // Save settings, but wiping all tip data
  532. NVIC_SystemReset();
  533. break;
  534. case 3: // Reset everything
  535. resetSystemSettings(); // Reset system settings
  536. saveSettings(saveWipingProfiles); // Save settings wiping all tip data
  537. NVIC_SystemReset();
  538. break;
  539. default:
  540. return screen_main;
  541. }
  542. }
  543. static int goSettingsReset(void) {
  544. resStatus=0;
  545. return screen_reset_confirmation;
  546. }
  547. static int goProfileReset(void) {
  548. resStatus=1;
  549. return screen_reset_confirmation;
  550. }
  551. static int goAllProfileReset(void) {
  552. resStatus=2;
  553. return screen_reset_confirmation;
  554. }
  555. static int goFactoryReset(void) {
  556. resStatus=3;
  557. return screen_reset_confirmation;
  558. }
  559. static void setButtonWake(uint32_t *val) {
  560. systemSettings.settings.wakeOnButton = *val;
  561. }
  562. static void * getButtonWake() {
  563. temp = systemSettings.settings.wakeOnButton;
  564. return &temp;
  565. }
  566. static void setShakeWake(uint32_t *val) {
  567. systemSettings.settings.wakeOnShake = *val;
  568. }
  569. static void * getShakeWake() {
  570. temp = systemSettings.settings.wakeOnShake;
  571. return &temp;
  572. }
  573. //-------------------------------------------------------------------------------------------------------------------------------
  574. // Settings screen functions
  575. //-------------------------------------------------------------------------------------------------------------------------------
  576. static void settings_screen_init(screen_t *scr) {
  577. default_init(scr);
  578. scr->current_widget = &comboWidget_Settings;
  579. comboBox_IRONTIPS.selectable.state = widget_selected;
  580. settingsTimer=HAL_GetTick();
  581. }
  582. static void settings_screen_OnEnter(screen_t *scr) {
  583. if(scr==&Screen_main){
  584. comboResetIndex(&comboWidget_Settings);
  585. }
  586. }
  587. int settings_screenProcessInput(screen_t * scr, RE_Rotation_t input, RE_State_t *state) {
  588. if(input!=Rotate_Nothing){
  589. settingsTimer=HAL_GetTick();
  590. }
  591. if((input==LongClick) || (HAL_GetTick()-settingsTimer)>15000){
  592. return screen_main;
  593. }
  594. return default_screenProcessInput(scr, input, state);
  595. }
  596. //-------------------------------------------------------------------------------------------------------------------------------
  597. // Edit Tip Name screen functions
  598. //-------------------------------------------------------------------------------------------------------------------------------
  599. void edit_tip_screen_init(screen_t *scr) {
  600. if(Tip_name_return == screen_edit_iron_tips && comboBox_IRONTIPS.currentItem == &comboitem_IRONTIPS_addNewTip) { // If we were in iron tips screen and came from "Add new tip"
  601. strcpy(str, " "); // Copy blank str
  602. widgetDisable(&Widget_IRONTIPS_Name_Delete); // Disable delete widget
  603. }
  604. else { // Already existing tip
  605. strcpy(str, systemSettings.Profile.tip[Selected_Tip].name); // Copy tip name
  606. if(systemSettings.Profile.currentNumberOfTips>1){ // If more than 1 tip in the system, enable delete
  607. widgetEnable(&Widget_IRONTIPS_Name_Delete);
  608. }
  609. else{
  610. widgetDisable(&Widget_IRONTIPS_Name_Delete);
  611. }
  612. }
  613. scr->current_widget=&Widget_IRONTIPS_Name_Edit;
  614. editable_IRONTIPS_Name_Edit.selectable.previous_state=widget_idle;
  615. editable_IRONTIPS_Name_Edit.selectable.state=widget_selected;
  616. button_IRONTIPS_Name_Save.selectable.previous_state=widget_idle;
  617. button_IRONTIPS_Name_Save.selectable.state=widget_idle;
  618. button_IRONTIPS_Name_Back.selectable.previous_state=widget_idle;
  619. button_IRONTIPS_Name_Back.selectable.state=widget_idle;
  620. button_IRONTIPS_Name_Delete.selectable.previous_state=widget_idle;
  621. button_IRONTIPS_Name_Delete.selectable.state=widget_idle;
  622. u8g2_SetFont(&u8g2,default_font);
  623. u8g2_SetDrawColor(&u8g2, WHITE);
  624. u8g2_DrawStr(&u8g2,20,19,"NAME:");
  625. widgetDisable(&Widget_IRONTIPS_Name_Save);
  626. default_init(scr);
  627. }
  628. int edit_tip_screen_screenProcessInput(screen_t * scr, RE_Rotation_t input, RE_State_t *state) {
  629. int val = default_screenProcessInput(scr, input, state);
  630. if(input!=Rotate_Nothing){
  631. settingsTimer=HAL_GetTick();
  632. if(editable_IRONTIPS_Name_Edit.selectable.state==widget_edit){ // If tip name is being edited and there's encoder activity
  633. if(strcmp(str, " ") == 0){ // Check that the name is not empty
  634. widgetDisable(&Widget_IRONTIPS_Name_Save); // If empty, disable save widget
  635. }
  636. else{
  637. uint8_t x = 0;
  638. while(x<TipSize){ // Check existing name
  639. if(strcmp(str, systemSettings.Profile.tip[x].name) == 0){ // If match is found, disable save widget
  640. break;
  641. }
  642. x++;
  643. }
  644. if(x<TipSize){
  645. widgetDisable(&Widget_IRONTIPS_Name_Save);
  646. }
  647. else{
  648. widgetEnable(&Widget_IRONTIPS_Name_Save); // Else, enable widget
  649. }
  650. }
  651. }
  652. }
  653. else if((HAL_GetTick()-settingsTimer)>15000){
  654. return screen_main;
  655. }
  656. return val;
  657. }
  658. //-------------------------------------------------------------------------------------------------------------------------------
  659. // Tips screen functions
  660. //-------------------------------------------------------------------------------------------------------------------------------
  661. void edit_iron_screen_init(screen_t *scr) {
  662. comboBox_item_t *i = comboBox_IRONTIPS.first;
  663. for(int x = 0; x < TipSize; x++) {
  664. if(x < systemSettings.Profile.currentNumberOfTips) {
  665. strcpy(i->text, systemSettings.Profile.tip[x].name);
  666. i->enabled = 1;
  667. }
  668. else
  669. i->enabled = 0;
  670. i = i->next_item;
  671. }
  672. comboBox_IRONTIPS.currentItem = comboBox_IRONTIPS.first;
  673. comboBox_IRONTIPS.currentScroll = 0;
  674. comboitem_IRONTIPS_addNewTip.enabled = (systemSettings.Profile.currentNumberOfTips < TipSize);
  675. }
  676. void edit_iron_screen_onEnter(screen_t *scr) {
  677. if(scr == &Screen_edit_tip_settings){ // Normal edit
  678. Tip_name_return = screen_edit_tip_settings;
  679. }
  680. else if(scr == &Screen_edit_iron_tips){ // Coming from "Add new"
  681. Tip_name_return = screen_edit_iron_tips;
  682. }
  683. }
  684. int edit_iron_screen_screenProcessInput(screen_t * scr, RE_Rotation_t input, RE_State_t *state) {
  685. if(input!=Rotate_Nothing){
  686. settingsTimer=HAL_GetTick();
  687. }
  688. if((input==LongClick) || (HAL_GetTick()-settingsTimer)>15000){
  689. return screen_main;
  690. }
  691. return default_screenProcessInput(scr, input, state);
  692. }
  693. //-------------------------------------------------------------------------------------------------------------------------------
  694. // Reset screen functions
  695. //-------------------------------------------------------------------------------------------------------------------------------
  696. void Reset_onEnter(screen_t *scr){
  697. if(scr==&Screen_system){
  698. comboResetIndex(&comboWidget_RESET);
  699. }
  700. }
  701. //-------------------------------------------------------------------------------------------------------------------------------
  702. // Reset confirmation screen functions
  703. //-------------------------------------------------------------------------------------------------------------------------------
  704. void Reset_confirmation_onEnter(screen_t *scr){
  705. FillBuffer(BLACK, fill_dma); // Manually clear the screen
  706. Screen_reset_confirmation.refresh=screenRefresh_alreadyErased; // Set to already cleared so it doesn't get erased automatically
  707. u8g2_SetFont(&u8g2,default_font);
  708. u8g2_SetDrawColor(&u8g2, WHITE);
  709. switch(resStatus){
  710. case 0:
  711. putStrAligned("RESET SYSTEM", 0, align_center);
  712. putStrAligned("SETTINGS?", 16, align_center);
  713. break;
  714. case 1:
  715. putStrAligned("RESET CURRENT",0 , align_center);
  716. putStrAligned("PROFILE?", 16, align_center);
  717. break;
  718. case 2:
  719. putStrAligned("RESET ALL",0 , align_center);
  720. putStrAligned("PROFILES?", 16, align_center);
  721. break;
  722. case 3:
  723. putStrAligned("PERFORM FULL", 0, align_center);
  724. putStrAligned("SYSTEM RESET?", 16, align_center);
  725. break;
  726. }
  727. }
  728. //-------------------------------------------------------------------------------------------------------------------------------
  729. // IRONTIPS Settings screen functions
  730. //-------------------------------------------------------------------------------------------------------------------------------
  731. void IRONTIPS_Settings_onEnter(screen_t *scr){
  732. settingsTimer=HAL_GetTick();
  733. bool backup=0;
  734. comboResetIndex(&comboWidget_IRONTIPS_Settings);
  735. if(scr==&Screen_main){
  736. backup=1;
  737. comboitem_IRONTIPS_Settings_Cancel.action_screen = screen_main;
  738. Selected_Tip = systemSettings.Profile.currentTip;
  739. }
  740. else if(scr==&Screen_edit_iron_tips){
  741. backup=1;
  742. for(uint8_t x = 0; x < TipSize; x++) {
  743. if(strcmp(comboBox_IRONTIPS.currentItem->text, systemSettings.Profile.tip[x].name)==0){
  744. Selected_Tip = x;
  745. }
  746. }
  747. comboitem_IRONTIPS_Settings_Cancel.action_screen = screen_edit_iron_tips;
  748. }
  749. if(backup){
  750. tipCfg = systemSettings.Profile.tip[Selected_Tip];
  751. }
  752. comboitem_IRONTIPS_Settings_TipLabel.text = tipCfg.name;
  753. }
  754. //-------------------------------------------------------------------------------------------------------------------------------
  755. // IRON settings screen functions
  756. //-------------------------------------------------------------------------------------------------------------------------------
  757. void IRON_onEnter(screen_t *scr){
  758. setSettingsScrTempUnit();
  759. comboResetIndex(&comboWidget_IRON);
  760. }
  761. //-------------------------------------------------------------------------------------------------------------------------------
  762. // SYSTEM settings screen functions
  763. //-------------------------------------------------------------------------------------------------------------------------------
  764. void SYSTEM_onEnter(screen_t *scr){
  765. setSettingsScrTempUnit();
  766. if(scr!=&Screen_reset){
  767. comboResetIndex(&comboWidget_SYSTEM);
  768. }
  769. if(ChecksumProfile(&systemSettings.Profile)!=systemSettings.ProfileChecksum){ // If there's unsaved profile data
  770. saveSettings(saveKeepingProfiles); // Save settings
  771. }
  772. profile=systemSettings.settings.currentProfile;
  773. }
  774. void SYSTEM_onExit(screen_t *scr){
  775. if(profile!=systemSettings.settings.currentProfile){ // If profile changed
  776. loadProfile(profile);
  777. saveSettings(saveKeepingProfiles); // Save
  778. }
  779. }
  780. //-------------------------------------------------------------------------------------------------------------------------------
  781. // Settings screen setup
  782. //-------------------------------------------------------------------------------------------------------------------------------
  783. void settings_screen_setup(screen_t *scr) {
  784. screen_t* sc;
  785. widget_t* w;
  786. displayOnly_widget_t* dis;
  787. editable_widget_t* edit;
  788. screen_setDefaults(scr);
  789. scr->init = &settings_screen_init;
  790. scr->onEnter = &settings_screen_OnEnter;
  791. scr->processInput=&settings_screenProcessInput;
  792. //#################################### [ SETTINGS MAIN SCREEN ]#######################################
  793. //
  794. w = &comboWidget_Settings;
  795. screen_addWidget(w, scr);
  796. widgetDefaultsInit(w, widget_combo, &comboBox_Settings);
  797. comboAddScreen(&Settings_Combo_IRON, w, "IRON", screen_iron);
  798. comboAddScreen(&Settings_Combo_SYSTEM, w, "SYSTEM", screen_system);
  799. comboAddScreen(&Settings_Combo_TIPS, w, "EDIT TIPS", screen_edit_iron_tips);
  800. comboAddScreen(&Settings_Combo_CALIBRATION, w, "CALIBRATION", screen_edit_calibration);
  801. #ifdef ENABLE_DEBUG_SCREEN
  802. comboAddScreen(&Settings_Combo_DEBUG, w, "DEBUG", screen_debug);
  803. #endif
  804. comboAddScreen(&Settings_Combo_EXIT, w, "EXIT", screen_main);
  805. //########################################## SYSTEM SCREEN ##########################################
  806. //
  807. sc=&Screen_system;
  808. oled_addScreen(sc,screen_system);
  809. screen_setDefaults(sc);
  810. sc->onEnter = &SYSTEM_onEnter;
  811. sc->onExit = &SYSTEM_onExit;
  812. sc->processInput=&settings_screenProcessInput;
  813. //********[ Profile Widget ]***********************************************************
  814. //
  815. dis=&editable_SYSTEM_Profile.inputData;
  816. edit=&editable_SYSTEM_Profile;
  817. editableDefaultsInit(edit,widget_multi_option);
  818. dis->getData = &getProfile;
  819. edit->big_step = 1;
  820. edit->step = 1;
  821. edit->setData = (void (*)(void *))&setProfile;
  822. edit->max_value = ProfileSize-1;
  823. edit->min_value = 0;
  824. edit->options = profileStr;
  825. edit->numberOfOptions = ProfileSize;
  826. //********[ Contrast Widget ]***********************************************************
  827. //
  828. dis=&editable_SYSTEM_Contrast.inputData;
  829. edit=&editable_SYSTEM_Contrast;
  830. editableDefaultsInit(edit,widget_editable);
  831. dis->reservedChars=3;
  832. dis->getData = &getContrast_;
  833. edit->big_step = 25;
  834. edit->step = 1;
  835. edit->setData = (void (*)(void *))&setContrast_;
  836. edit->max_value = 255;
  837. edit->min_value = 5;
  838. //********[ Oled Offset Widget ]***********************************************************
  839. //
  840. dis=&editable_SYSTEM_OledOffset.inputData;
  841. edit=&editable_SYSTEM_OledOffset;
  842. editableDefaultsInit(edit,widget_editable);
  843. dis->reservedChars=2;
  844. dis->getData = &getOledOffset;
  845. edit->big_step = 10;
  846. edit->step = 1;
  847. edit->setData = (void (*)(void *))&setOledOffset;
  848. edit->max_value = 15;
  849. edit->min_value = 0;
  850. //********[ Oled dimming Widget ]***********************************************************
  851. //
  852. dis=&editable_SYSTEM_OledDimming.inputData;
  853. edit=&editable_SYSTEM_OledDimming;
  854. editableDefaultsInit(edit,widget_multi_option);
  855. dis->getData = &getOledDimming;
  856. edit->big_step = 1;
  857. edit->step = 1;
  858. edit->setData = (void (*)(void *))&setOledDimming;
  859. edit->max_value = 1;
  860. edit->min_value = 0;
  861. edit->options = OffOn;
  862. edit->numberOfOptions = 2;
  863. //********[ Wake mode Widget ]***********************************************************
  864. //
  865. dis=&editable_SYSTEM_WakeMode.inputData;
  866. edit=&editable_SYSTEM_WakeMode;
  867. editableDefaultsInit(edit,widget_multi_option);
  868. dis->getData = &getWakeMode;
  869. edit->big_step = 1;
  870. edit->step = 1;
  871. edit->setData = (void (*)(void *))&setWakeMode;
  872. edit->max_value = wakeInputmode_stand;
  873. edit->min_value = wakeInputmode_shake;
  874. edit->options = wakeMode;
  875. edit->numberOfOptions = 2;
  876. //********[ Stand mode Widget ]***********************************************************
  877. //
  878. dis=&editable_SYSTEM_StandMode.inputData;
  879. edit=&editable_SYSTEM_StandMode;
  880. editableDefaultsInit(edit,widget_multi_option);
  881. dis->getData = &getStandMode;
  882. edit->big_step = 1;
  883. edit->step = 1;
  884. edit->setData = (void (*)(void *))&setStandMode;
  885. edit->max_value = mode_standby;
  886. edit->min_value = mode_sleep;
  887. edit->options = InitMode;
  888. edit->numberOfOptions = 2;
  889. //********[ Encoder inversion Widget ]***********************************************************
  890. //
  891. dis=&editable_SYSTEM_EncoderMode.inputData;
  892. edit=&editable_SYSTEM_EncoderMode;
  893. editableDefaultsInit(edit,widget_multi_option);
  894. dis->getData = &getEncoderMode;
  895. edit->big_step = 1;
  896. edit->step = 1;
  897. edit->setData = (void (*)(void *))&setEncoderMode;
  898. edit->max_value = encoder_reverse;
  899. edit->min_value = encoder_normal;
  900. edit->options = encMode;
  901. edit->numberOfOptions = 2;
  902. //********[ Save Delay Widget ]***********************************************************
  903. //
  904. dis=&editable_SYSTEM_SaveInterval.inputData;
  905. edit=&editable_SYSTEM_SaveInterval;
  906. editableDefaultsInit(edit,widget_editable);
  907. dis->reservedChars=3;
  908. dis->endString="s";
  909. dis->getData = &getSavDelay;
  910. edit->big_step = 1;
  911. edit->step = 1;
  912. edit->setData = (void (*)(void *))&setSavDelay;
  913. edit->max_value = 60;
  914. edit->min_value = 0;
  915. //********[ Gui refresh rate Widget ]***********************************************************
  916. //
  917. dis=&editable_SYSTEM_GuiUpd.inputData;
  918. edit=&editable_SYSTEM_GuiUpd;
  919. editableDefaultsInit(edit,widget_editable);
  920. dis->endString="mS";
  921. dis->reservedChars=5;
  922. dis->getData = &getGuiUpd_ms;
  923. edit->big_step = 50;
  924. edit->step = 10;
  925. edit->setData = (void (*)(void *))&setGuiUpd_ms;
  926. edit->max_value = 500;
  927. edit->min_value = 20;
  928. //********[ Temp display unit Widget ]***********************************************************
  929. //
  930. dis=&editable_SYSTEM_TempUnit.inputData;
  931. edit=&editable_SYSTEM_TempUnit;
  932. editableDefaultsInit(edit,widget_multi_option);
  933. dis->getData = &getTmpUnit;
  934. edit->big_step = 1;
  935. edit->step = 1;
  936. edit->setData = (void (*)(void *))&setTmpUnit;
  937. edit->max_value = mode_Farenheit;
  938. edit->min_value = mode_Celsius;
  939. edit->options = tempUnit;
  940. edit->numberOfOptions = 2;
  941. //********[ Temp step Widget ]***********************************************************
  942. //
  943. dis=&editable_SYSTEM_TempStep.inputData;
  944. edit=&editable_SYSTEM_TempStep;
  945. editableDefaultsInit(edit,widget_editable);
  946. dis->reservedChars=4;
  947. dis->getData = &getTmpStep;
  948. edit->big_step = 5;
  949. edit->step = 1;
  950. edit->setData = (void (*)(void *))&setTmpStep;
  951. edit->max_value = 50;
  952. edit->min_value = 1;
  953. //********[ Buzzer Widget ]***********************************************************
  954. //
  955. dis=&editable_SYSTEM_Buzzer.inputData;
  956. edit=&editable_SYSTEM_Buzzer;
  957. editableDefaultsInit(edit,widget_multi_option);
  958. dis->getData = &getbuzzerMode;
  959. edit->big_step = 1;
  960. edit->step = 1;
  961. edit->setData = (void (*)(void *))&setbuzzerMode;
  962. edit->max_value = 1;
  963. edit->min_value = 0;
  964. edit->options = OffOn;
  965. edit->numberOfOptions = 2;
  966. //********[ Init mode Widget ]***********************************************************
  967. //
  968. dis=&editable_SYSTEM_InitMode.inputData;
  969. edit=&editable_SYSTEM_InitMode;
  970. editableDefaultsInit(edit,widget_multi_option);
  971. dis->getData = &getInitMode;
  972. edit->big_step = 1;
  973. edit->step = 1;
  974. edit->setData = (void (*)(void *))&setInitMode;
  975. edit->max_value = mode_run;
  976. edit->min_value = mode_sleep;
  977. edit->options = InitMode;
  978. edit->numberOfOptions = 3;
  979. //********[ Encoder wake Widget ]***********************************************************
  980. //
  981. dis=&editable_SYSTEM_ButtonWake.inputData;
  982. edit=&editable_SYSTEM_ButtonWake;
  983. editableDefaultsInit(edit,widget_multi_option);
  984. dis->getData = &getButtonWake;
  985. edit->big_step = 1;
  986. edit->step = 1;
  987. edit->setData = (void (*)(void *))&setButtonWake;
  988. edit->max_value = 1;
  989. edit->min_value = 0;
  990. edit->options =OffOn;
  991. edit->numberOfOptions = 2;
  992. //********[ Shake wake Widget ]***********************************************************
  993. //
  994. dis=&editable_SYSTEM_ShakeWake.inputData;
  995. edit=&editable_SYSTEM_ShakeWake;
  996. editableDefaultsInit(edit,widget_multi_option);
  997. dis->getData = &getShakeWake;
  998. edit->big_step = 1;
  999. edit->step = 1;
  1000. edit->setData = (void (*)(void *))&setShakeWake;
  1001. edit->max_value = 1;
  1002. edit->min_value = 0;
  1003. edit->options = OffOn;
  1004. edit->numberOfOptions = 2;
  1005. //********[ Active detection Widget ]***********************************************************
  1006. //
  1007. dis=&editable_SYSTEM_ActiveDetection.inputData;
  1008. edit=&editable_SYSTEM_ActiveDetection;
  1009. editableDefaultsInit(edit,widget_multi_option);
  1010. dis->getData = &getActiveDetection;
  1011. edit->big_step = 1;
  1012. edit->step = 1;
  1013. edit->setData = (void (*)(void *))&setActiveDetection;
  1014. edit->max_value = 1;
  1015. edit->min_value = 0;
  1016. edit->options = OffOn;
  1017. edit->numberOfOptions = 2;
  1018. //********[ Low voltage protection Widget ]***********************************************************
  1019. //
  1020. dis=&editable_SYSTEM_LVP.inputData;
  1021. edit=&editable_SYSTEM_LVP;
  1022. editableDefaultsInit(edit,widget_editable);
  1023. dis->endString="V";
  1024. dis->reservedChars=5;
  1025. dis->getData = &getLVP;
  1026. dis->number_of_dec = 1;
  1027. edit->big_step = 10;
  1028. edit->step = 1;
  1029. edit->setData = (void (*)(void *))&setLVP;
  1030. edit->max_value = 240;
  1031. edit->min_value = 90;
  1032. //========[ SYSTEM COMBO ]===========================================================
  1033. //
  1034. w = &comboWidget_SYSTEM;
  1035. screen_addWidget(w, sc);
  1036. widgetDefaultsInit(w, widget_combo, &comboBox_SYSTEM);
  1037. comboAddMultiOption(&comboitem_SYSTEM_Profile,w, "Profile", &editable_SYSTEM_Profile);
  1038. comboAddEditable(&comboitem_SYSTEM_Contrast,w, "Contrast", &editable_SYSTEM_Contrast);
  1039. comboAddMultiOption(&comboitem_SYSTEM_OledDimming,w, "Auto dim", &editable_SYSTEM_OledDimming);
  1040. comboAddEditable(&comboitem_SYSTEM_OledOffset, w, "Offset", &editable_SYSTEM_OledOffset);
  1041. comboAddMultiOption(&comboitem_SYSTEM_EncoderMode, w, "Encoder", &editable_SYSTEM_EncoderMode);
  1042. comboAddMultiOption(&comboitem_SYSTEM_WakeMode, w, "Wake Mode", &editable_SYSTEM_WakeMode);
  1043. comboAddMultiOption(&comboitem_SYSTEM_InitMode, w, "Boot", &editable_SYSTEM_InitMode);
  1044. comboAddMultiOption(&comboitem_SYSTEM_StandMode, w, "Stand idle", &editable_SYSTEM_StandMode);
  1045. comboAddMultiOption(&comboitem_SYSTEM_ButtonWake, w, "Btn. wake", &editable_SYSTEM_ButtonWake);
  1046. comboAddMultiOption(&comboitem_SYSTEM_ShakeWake, w, "Shake wake", &editable_SYSTEM_ShakeWake);
  1047. comboAddMultiOption(&comboitem_SYSTEM_ActiveDetection, w, "Active det.",&editable_SYSTEM_ActiveDetection);
  1048. comboAddMultiOption(&comboitem_SYSTEM_Buzzer, w, "Buzzer", &editable_SYSTEM_Buzzer);
  1049. comboAddMultiOption(&comboitem_SYSTEM_TempUnit, w, "Unit", &editable_SYSTEM_TempUnit);
  1050. comboAddEditable(&comboitem_SYSTEM_TempStep, w, "Step", &editable_SYSTEM_TempStep);
  1051. comboAddEditable(&comboitem_SYSTEM_LVP, w, "LVP", &editable_SYSTEM_LVP);
  1052. comboAddEditable(&comboitem_SYSTEM_GuiUpd, w, "Gui time", &editable_SYSTEM_GuiUpd);
  1053. comboAddEditable(&comboitem_SYSTEM_SaveInterval, w, "Save time", &editable_SYSTEM_SaveInterval);
  1054. comboAddScreen(&comboitem_SYSTEM_Reset, w, "RESET MENU", screen_reset);
  1055. comboAddScreen(&comboitem_SYSTEM_SW, w, SWSTRING, -1);
  1056. comboAddScreen(&comboitem_SYSTEM_HW, w, HWSTRING, -1);
  1057. comboAddScreen(&comboitem_SYSTEM_Back, w, "BACK", screen_settingsmenu);
  1058. //########################################## RESET SCREEN ##########################################
  1059. //
  1060. sc=&Screen_reset;
  1061. oled_addScreen(sc, screen_reset);
  1062. screen_setDefaults(sc);
  1063. sc->onEnter = &Reset_onEnter;
  1064. sc->processInput=&settings_screenProcessInput;
  1065. //========[ RESET OPTIONS COMBO ]===========================================================
  1066. //
  1067. w = &comboWidget_RESET;
  1068. screen_addWidget(w, sc);
  1069. widgetDefaultsInit(w, widget_combo, &comboBox_RESET);
  1070. comboAddAction(&comboitem_RESET_SETTINGS,w, "Reset Settings", &goSettingsReset );
  1071. comboAddAction(&comboitem_RESET_TIP,w, "Reset Profile", &goProfileReset );
  1072. comboAddAction(&comboitem_RESET_ALLTIP,w, "Reset Profiles", &goAllProfileReset );
  1073. comboAddAction(&comboitem_RESET_EVERYTHING,w, "Reset All", &goFactoryReset);
  1074. comboAddScreen(&comboitem_RESET_Back,w, "BACK", screen_system);
  1075. comboitem_RESET_SETTINGS.dispAlign=align_left;
  1076. comboitem_RESET_TIP.dispAlign=align_left;
  1077. comboitem_RESET_ALLTIP.dispAlign=align_left;
  1078. comboitem_RESET_EVERYTHING.dispAlign=align_left;
  1079. //########################################## RESET CONFIRMATION SCREEN ##########################################
  1080. //
  1081. sc=&Screen_reset_confirmation;
  1082. oled_addScreen(sc, screen_reset_confirmation);
  1083. screen_setDefaults(sc);
  1084. sc->onEnter = &Reset_confirmation_onEnter;
  1085. sc->processInput=&settings_screenProcessInput;
  1086. // ********[ Name Save Button Widget ]***********************************************************
  1087. //
  1088. w = &Widget_Reset_OK;
  1089. screen_addWidget(w,sc);
  1090. widgetDefaultsInit(w, widget_button, &button_Reset_OK);
  1091. button_Reset_OK.displayString="RESET";
  1092. w->posX = 0;
  1093. w->posY = 48;
  1094. w->width = 50;
  1095. ((button_widget_t*)w->content)->selectable.tab = 1;
  1096. ((button_widget_t*)w->content)->action = &doReset;
  1097. // ********[ Name Back Button Widget ]***********************************************************
  1098. //
  1099. w = &Widget_Reset_CANCEL;
  1100. screen_addWidget(w,sc);
  1101. widgetDefaultsInit(w, widget_button, &button_Reset_CANCEL);
  1102. button_Reset_CANCEL.displayString="CANCEL";
  1103. w->posX = 72;
  1104. w->posY = 48;
  1105. w->width = 56;
  1106. ((button_widget_t*)w->content)->selectable.tab = 0;
  1107. ((button_widget_t*)w->content)->action = &cancelReset;
  1108. //########################################## IRON SCREEN ##########################################
  1109. //
  1110. sc=&Screen_iron;
  1111. oled_addScreen(sc,screen_iron);
  1112. screen_setDefaults(sc);
  1113. sc->onEnter = &IRON_onEnter;
  1114. sc->processInput=&settings_screenProcessInput;
  1115. //********[ Sleep Time Widget ]***********************************************************
  1116. //
  1117. dis=&editable_IRON_SleepTime.inputData;
  1118. edit=&editable_IRON_SleepTime;
  1119. editableDefaultsInit(edit,widget_editable);
  1120. dis->endString="min";
  1121. dis->reservedChars=5;
  1122. dis->getData = &getSleepTime;
  1123. edit->big_step = 5;
  1124. edit->step = 1;
  1125. edit->setData = (void (*)(void *))&setSleepTime;
  1126. edit->max_value = 60;
  1127. edit->min_value = 0;
  1128. //********[ Stby Time Widget ]***********************************************************
  1129. //
  1130. dis=&editable_IRON_StandbyTime.inputData;
  1131. edit=&editable_IRON_StandbyTime;
  1132. editableDefaultsInit(edit,widget_editable);
  1133. dis->endString="min";
  1134. dis->reservedChars=5;
  1135. dis->getData = &getStandbyTime;
  1136. edit->big_step = 5;
  1137. edit->step = 1;
  1138. edit->setData = (void (*)(void *))&setStandbyTime;
  1139. edit->max_value = 60;
  1140. edit->min_value = 0;
  1141. //********[ Stby Temp Widget ]***********************************************************
  1142. //
  1143. dis=&editable_IRON_StandbyTemp.inputData;
  1144. edit=&editable_IRON_StandbyTemp;
  1145. editableDefaultsInit(edit,widget_editable);
  1146. dis->endString="C";
  1147. dis->reservedChars=5;
  1148. dis->getData = &getStandbyTemp;
  1149. edit->big_step = 10;
  1150. edit->step = 5;
  1151. edit->max_value = 350;
  1152. edit->min_value = 50;
  1153. edit->setData = (void (*)(void *))&setStandbyTemp;
  1154. #ifdef USE_VIN
  1155. //********[ Power Widget ]***********************************************************
  1156. //
  1157. dis=&editable_IRON_Power.inputData;
  1158. edit=&editable_IRON_Power;
  1159. editableDefaultsInit(edit,widget_editable);
  1160. dis->reservedChars=4;
  1161. dis->endString="W";
  1162. dis->getData = &getMaxPower;
  1163. edit->big_step = 20;
  1164. edit->step = 5;
  1165. edit->setData = (void (*)(void *))&setMaxPower;
  1166. edit->max_value = 500;
  1167. edit->min_value = 5;
  1168. //********[ Impedance Widget ]***********************************************************
  1169. //
  1170. dis=&editable_IRON_Impedance.inputData;
  1171. edit=&editable_IRON_Impedance;
  1172. editableDefaultsInit(edit,widget_editable);
  1173. dis->reservedChars=4;
  1174. dis->number_of_dec=1;
  1175. //dis->endString="";
  1176. dis->getData = &getTipImpedance;
  1177. edit->big_step = 10;
  1178. edit->step = 1;
  1179. edit->setData = (void (*)(void *))&setTipImpedance;
  1180. edit->max_value = 160;
  1181. edit->min_value = 10;
  1182. #endif
  1183. //********[ Max Temp Widget ]***********************************************************
  1184. //
  1185. dis=&editable_IRON_MaxTemp.inputData;
  1186. edit=&editable_IRON_MaxTemp;
  1187. editableDefaultsInit(edit,widget_editable);
  1188. dis->reservedChars=5;
  1189. dis->getData = &getMaxTemp;
  1190. edit->big_step = 10;
  1191. edit->step = 5;
  1192. edit->max_value = 480;
  1193. edit->setData = (void (*)(void *))&setMaxTemp;
  1194. //********[ Min Temp Widget ]***********************************************************
  1195. //
  1196. dis=&editable_IRON_MinTemp.inputData;
  1197. edit=&editable_IRON_MinTemp;
  1198. editableDefaultsInit(edit,widget_editable);
  1199. dis->reservedChars=5;
  1200. dis->getData = &getMinTemp;
  1201. edit->big_step = 10;
  1202. edit->step = 5;
  1203. edit->max_value = 480;
  1204. edit->min_value = 50;
  1205. edit->setData = (void (*)(void *))&setMinTemp;
  1206. //********[ ADC Limit Widget ]***********************************************************
  1207. //
  1208. dis=&editable_IRON_ADCLimit.inputData;
  1209. edit=&editable_IRON_ADCLimit;
  1210. editableDefaultsInit(edit,widget_editable);
  1211. dis->reservedChars=4;
  1212. dis->getData = &getNoIronADC;
  1213. edit->big_step = 200;
  1214. edit->step = 10;
  1215. edit->setData = (void (*)(void *))&setNoIronADC;
  1216. edit->max_value = 4100;
  1217. edit->min_value = 200;
  1218. //********[ PWM Period Widget ]***********************************************************
  1219. //
  1220. dis=&editable_IRON_PWMPeriod.inputData;
  1221. edit=&editable_IRON_PWMPeriod;
  1222. editableDefaultsInit(edit,widget_editable);
  1223. dis->endString="mS";
  1224. dis->reservedChars=5;
  1225. dis->getData = &getPWMPeriod;
  1226. edit->big_step = 10;
  1227. edit->step = 1;
  1228. edit->setData = (void (*)(void *))&setPWMPeriod;
  1229. edit->max_value = 200;
  1230. edit->min_value = 20;
  1231. //********[ ADC Delay Widget ]***********************************************************
  1232. //
  1233. dis=&editable_IRON_ADCDelay.inputData;
  1234. edit=&editable_IRON_ADCDelay;
  1235. editableDefaultsInit(edit,widget_editable);
  1236. dis->endString="mS";
  1237. dis->reservedChars=7;
  1238. dis->number_of_dec = 1;
  1239. dis->getData = &getPWMDelay;
  1240. edit->big_step = 10;
  1241. edit->step = 1;
  1242. edit->setData = (void (*)(void *))&setPWMDelay;
  1243. edit->max_value = 500;
  1244. edit->min_value = 1;
  1245. //********[ Filter Coefficient Widget ]***********************************************************
  1246. //
  1247. dis=&editable_IRON_filterFactor.inputData;
  1248. edit=&editable_IRON_filterFactor;
  1249. editableDefaultsInit(edit,widget_editable);
  1250. dis->reservedChars=1;
  1251. dis->getData = &getfilterFactor;
  1252. edit->big_step = 1;
  1253. edit->step = 1;
  1254. edit->setData = (void (*)(void *))&setfilterFactor;
  1255. edit->max_value = 8;
  1256. edit->min_value = 0;
  1257. //********[ No Iron Delay Widget ]***********************************************************
  1258. //
  1259. dis=&editable_IRON_errorDelay.inputData;
  1260. edit=&editable_IRON_errorDelay;
  1261. editableDefaultsInit(edit,widget_editable);
  1262. dis->endString="mS";
  1263. dis->reservedChars=5;
  1264. dis->getData = &geterrorDelay;
  1265. edit->big_step = 100;
  1266. edit->step = 50;
  1267. edit->setData = (void (*)(void *))&seterrorDelay;
  1268. edit->max_value = 950;
  1269. edit->min_value = 100;
  1270. //========[ IRON COMBO ]===========================================================
  1271. //
  1272. w = &comboWidget_IRON;
  1273. screen_addWidget(w, sc);
  1274. widgetDefaultsInit(w, widget_combo, &comboBox_IRON);
  1275. comboAddEditable(&comboitem_IRON_MaxTemp, w, "Max temp", &editable_IRON_MaxTemp);
  1276. comboAddEditable(&comboitem_IRON_MinTemp, w, "Min temp", &editable_IRON_MinTemp);
  1277. comboAddEditable(&comboitem_IRON_StandbyTemp, w, "Stby temp", &editable_IRON_StandbyTemp);
  1278. comboAddEditable(&comboitem_IRON_StandbyTime, w, "Stby time", &editable_IRON_StandbyTime);
  1279. comboAddEditable(&comboitem_IRON_SleepTime, w, "Sleep time", &editable_IRON_SleepTime);
  1280. #ifdef USE_VIN
  1281. comboAddEditable(&comboitem_IRON_Impedance, w, "Heater ohm", &editable_IRON_Impedance);
  1282. comboAddEditable(&comboitem_IRON_Power, w, "Power", &editable_IRON_Power);
  1283. #endif
  1284. comboAddEditable(&comboitem_IRON_PWMPeriod,w, "PWM", &editable_IRON_PWMPeriod);
  1285. comboAddEditable(&comboitem_IRON_ADCDelay, w, "Delay", &editable_IRON_ADCDelay);
  1286. comboAddEditable(&comboitem_IRON_filterFactor, w, "Filter", &editable_IRON_filterFactor);
  1287. comboAddEditable(&comboitem_IRON_ADCLimit, w, "No iron", &editable_IRON_ADCLimit);
  1288. comboAddEditable(&comboitem_IRON_errorDelay, w, "Detect", &editable_IRON_errorDelay);
  1289. comboAddScreen(&comboitem_IRON_Back, w, "BACK", screen_settingsmenu);
  1290. //########################################## IRON TIPS SCREEN ##########################################
  1291. //
  1292. sc=&Screen_edit_iron_tips;
  1293. oled_addScreen(sc, screen_edit_iron_tips);
  1294. screen_setDefaults(sc);
  1295. sc->init = &edit_iron_screen_init;
  1296. sc->processInput=&edit_iron_screen_screenProcessInput;
  1297. //========[ IRON TIPS COMBO ]===========================================================
  1298. //
  1299. w = &comboWidget_IRONTIPS;
  1300. w->content = &comboBox_IRONTIPS;
  1301. screen_addWidget(w,sc);
  1302. widgetDefaultsInit(w, widget_combo, &comboBox_IRONTIPS);
  1303. for(int x = 0; x < TipSize; x++) {
  1304. t[x][0] = '\0';
  1305. comboAddScreen(&comboitem_IRONTIPS[x],w, &t[x][0], screen_edit_tip_settings);
  1306. }
  1307. comboAddScreen(&comboitem_IRONTIPS_addNewTip, w, "ADD NEW", screen_edit_tip_name);
  1308. comboAddScreen(&comboitem_IRONTIPS_Back, w, "BACK", screen_settingsmenu);
  1309. //########################################## IRON TIP EDIT NAME SCREEN ##########################################
  1310. //
  1311. sc=&Screen_edit_tip_name;
  1312. oled_addScreen(sc, screen_edit_tip_name);
  1313. screen_setDefaults(sc);
  1314. sc->processInput = &edit_tip_screen_screenProcessInput;
  1315. sc->init = &edit_tip_screen_init;
  1316. sc->onEnter= &edit_iron_screen_onEnter;
  1317. //********[ Name Edit Widget ]***********************************************************
  1318. //
  1319. w = &Widget_IRONTIPS_Name_Edit;
  1320. screen_addWidget(w,sc);
  1321. widgetDefaultsInit(w, widget_editable, &editable_IRONTIPS_Name_Edit);
  1322. dis=extractDisplayPartFromWidget(w);
  1323. edit=extractEditablePartFromWidget(w);
  1324. dis->reservedChars=TipCharSize-1;
  1325. w->posX = 75;
  1326. w->posY = 17;
  1327. w->width = 46;
  1328. dis->getData = &getTipStr;
  1329. dis->number_of_dec = 0;
  1330. dis->type = field_string;
  1331. edit->big_step = 10;
  1332. edit->step = 1;
  1333. edit->selectable.tab = 0;
  1334. edit->setData = (void (*)(void *))&setTipStr;
  1335. //********[ Name Save Button Widget ]***********************************************************
  1336. //
  1337. w = &Widget_IRONTIPS_Name_Save;
  1338. screen_addWidget(w,sc);
  1339. widgetDefaultsInit(w, widget_button, &button_IRONTIPS_Name_Save);
  1340. button_IRONTIPS_Name_Save.displayString="SAVE";
  1341. w->posX = 0;
  1342. w->posY = 48;
  1343. w->width = 42;
  1344. ((button_widget_t*)w->content)->selectable.tab = 3;
  1345. ((button_widget_t*)w->content)->action = &saveTip;
  1346. //********[ Name Back Button Widget ]***********************************************************
  1347. //
  1348. w = &Widget_IRONTIPS_Name_Back;
  1349. screen_addWidget(w,sc);
  1350. widgetDefaultsInit(w, widget_button, &button_IRONTIPS_Name_Back);
  1351. button_IRONTIPS_Name_Back.displayString="BACK";
  1352. w->posX = 86;
  1353. w->posY = 48;
  1354. w->width = 42;
  1355. ((button_widget_t*)w->content)->selectable.tab = 1;
  1356. ((button_widget_t*)w->content)->action = &cancelTip;
  1357. //********[ Name Delete Button Widget ]***********************************************************
  1358. //
  1359. w = &Widget_IRONTIPS_Name_Delete;
  1360. screen_addWidget(w,sc);
  1361. widgetDefaultsInit(w, widget_button, &button_IRONTIPS_Name_Delete);
  1362. button_IRONTIPS_Name_Delete.displayString="DEL.";
  1363. w->posX = 43 ;
  1364. w->posY = 48;
  1365. w->width = 42;
  1366. ((button_widget_t*)w->content)->selectable.tab = 2;
  1367. ((button_widget_t*)w->content)->action = &delTip;
  1368. //########################################## [ TIP SETTINGS SCREEN ] ##########################################
  1369. //
  1370. sc=&Screen_edit_tip_settings;
  1371. oled_addScreen(sc,screen_edit_tip_settings);
  1372. screen_setDefaults(sc);
  1373. sc->onEnter = &IRONTIPS_Settings_onEnter;
  1374. sc->processInput=&settings_screenProcessInput;
  1375. //********[ TIP label]***********************************************************
  1376. //
  1377. comboitem_IRONTIPS_Settings_TipLabel.dispAlign = align_center;
  1378. //********[ KP Widget]***********************************************************
  1379. //
  1380. dis = &editable_IRONTIPS_Settings_PID_Kp.inputData;
  1381. edit = &editable_IRONTIPS_Settings_PID_Kp;
  1382. editableDefaultsInit(edit,widget_editable);
  1383. dis->reservedChars=6;
  1384. dis->getData = &getKp;
  1385. dis->number_of_dec = 2;
  1386. edit->max_value=65000;
  1387. edit->big_step = 500;
  1388. edit->step = 50;
  1389. edit->setData = (void (*)(void *))&setKp;
  1390. //********[ KI Widget ]***********************************************************
  1391. //
  1392. dis = &editable_IRONTIPS_Settings_PID_Ki.inputData;
  1393. edit = &editable_IRONTIPS_Settings_PID_Ki;
  1394. editableDefaultsInit(edit,widget_editable);
  1395. dis->reservedChars=6;
  1396. dis->getData = &getKi;
  1397. dis->number_of_dec = 2;
  1398. edit->max_value=65000;
  1399. edit->big_step = 500;
  1400. edit->step = 50;
  1401. edit->setData = (void (*)(void *))&setKi;
  1402. //********[ KD Widget ]***********************************************************
  1403. //
  1404. dis = &editable_IRONTIPS_Settings_PID_Kd.inputData;
  1405. edit = &editable_IRONTIPS_Settings_PID_Kd;
  1406. editableDefaultsInit(edit,widget_editable);
  1407. dis->reservedChars=6;
  1408. dis->getData = &getKd;
  1409. dis->number_of_dec = 2;
  1410. edit->max_value=65000;
  1411. edit->big_step = 500;
  1412. edit->step = 50;
  1413. edit->setData = (void (*)(void *))&setKd;
  1414. //********[ Imax Widget ]***********************************************************
  1415. //
  1416. dis = &editable_IRONTIPS_Settings_PID_Imax.inputData;
  1417. edit = &editable_IRONTIPS_Settings_PID_Imax;
  1418. editableDefaultsInit(edit,widget_editable);
  1419. dis->reservedChars=6;
  1420. dis->getData = &getImax;
  1421. dis->number_of_dec = 2;
  1422. edit->max_value=1000;
  1423. edit->big_step = 20;
  1424. edit->step = 1;
  1425. edit->setData = (void (*)(void *))&setImax;
  1426. //********[ Imin Widget ]***********************************************************
  1427. //
  1428. dis = &editable_IRONTIPS_Settings_PID_Imin.inputData;
  1429. edit = &editable_IRONTIPS_Settings_PID_Imin;
  1430. editableDefaultsInit(edit,widget_editable);
  1431. dis->reservedChars=6;
  1432. dis->getData = &getImin;
  1433. dis->number_of_dec = 2;
  1434. edit->max_value = 0;
  1435. edit->min_value = -1000;
  1436. edit->big_step = -20;
  1437. edit->step = -1;
  1438. edit->setData = (void (*)(void *))&setImin;
  1439. //********[ Cal250 Widget ]***********************************************************
  1440. //
  1441. dis = &editable_IRONTIPS_Settings_Cal250.inputData;
  1442. edit = &editable_IRONTIPS_Settings_Cal250;
  1443. editableDefaultsInit(edit,widget_editable);
  1444. dis->reservedChars=4;
  1445. dis->getData = &getCal250;
  1446. edit->max_value = 4095;
  1447. edit->min_value = 0;
  1448. edit->big_step = 50;
  1449. edit->step = 1;
  1450. edit->setData = (void (*)(void *))&setCal250;
  1451. //********[ Cal350 Widget ]***********************************************************
  1452. //
  1453. dis = &editable_IRONTIPS_Settings_Cal350.inputData;
  1454. edit = &editable_IRONTIPS_Settings_Cal350;
  1455. editableDefaultsInit(edit,widget_editable);
  1456. dis->reservedChars=4;
  1457. dis->getData = &getCal350;
  1458. edit->max_value = 4095;
  1459. edit->min_value = 0;
  1460. edit->big_step = 50;
  1461. edit->step = 1;
  1462. edit->setData = (void (*)(void *))&setCal350;
  1463. //********[ Cal450 Widget ]***********************************************************
  1464. //
  1465. dis = &editable_IRONTIPS_Settings_Cal450.inputData;
  1466. edit = &editable_IRONTIPS_Settings_Cal450;
  1467. editableDefaultsInit(edit,widget_editable);
  1468. dis->reservedChars=4;
  1469. dis->getData = &getCal450;
  1470. edit->max_value = 4095;
  1471. edit->min_value = 0;
  1472. edit->big_step = 50;
  1473. edit->step = 1;
  1474. edit->setData = (void (*)(void *))&setCal450;
  1475. //========[ PID COMBO ]===========================================================
  1476. //
  1477. w = &comboWidget_IRONTIPS_Settings;
  1478. screen_addWidget(w, sc);
  1479. widgetDefaultsInit(w, widget_combo, &comboBox_IRONTIPS_Settings);
  1480. comboAddScreen(&comboitem_IRONTIPS_Settings_TipLabel, w, "", screen_edit_tip_name); // Name set automatically on enter
  1481. comboAddEditable(&comboitem_IRONTIPS_Settings_PID_KP, w, "PID Kp", &editable_IRONTIPS_Settings_PID_Kp);
  1482. comboAddEditable(&comboitem_IRONTIPS_Settings_PID_KI, w, "PID Ki", &editable_IRONTIPS_Settings_PID_Ki);
  1483. comboAddEditable(&comboitem_IRONTIPS_Settings_PID_KD, w, "PID Kd", &editable_IRONTIPS_Settings_PID_Kd);
  1484. comboAddEditable(&comboitem_IRONTIPS_Settings_PID_Imax, w, "PID Imax", &editable_IRONTIPS_Settings_PID_Imax);
  1485. comboAddEditable(&comboitem_IRONTIPS_Settings_PID_Imin, w, "PID Imin", &editable_IRONTIPS_Settings_PID_Imin);
  1486. comboAddEditable(&comboitem_IRONTIPS_Settings_Cal250, w, "Cal250", &editable_IRONTIPS_Settings_Cal250);
  1487. comboAddEditable(&comboitem_IRONTIPS_Settings_Cal350, w, "Cal350", &editable_IRONTIPS_Settings_Cal350);
  1488. comboAddEditable(&comboitem_IRONTIPS_Settings_Cal450, w, "Cal450", &editable_IRONTIPS_Settings_Cal450);
  1489. comboAddAction(&comboitem_IRONTIPS_Settings_Save, w, "SAVE", &IRONTIPS_Save);
  1490. comboAddScreen(&comboitem_IRONTIPS_Settings_Cancel, w, "CANCEL", -1); // Return value set automatically on enter
  1491. }