main firmware: add variable editing, fix bug with holding

Users can now edit the program variables in order to customize their programs.
This commit is contained in:
true 2023-08-04 02:31:43 -07:00
parent d0d07b82f6
commit f475596dcc
3 changed files with 15 additions and 9 deletions

View File

@ -111,7 +111,7 @@
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.678171578" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.678171578" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.423553500" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.423553500" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.1644261835" name="Convert to Intel Hex file (-O ihex)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex" useByScannerDiscovery="false" value="true" valueType="boolean"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.1644261835" name="Convert to Intel Hex file (-O ihex)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary.1309566759" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary" useByScannerDiscovery="false" value="true" valueType="boolean"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary.1309566759" name="Convert to binary file (-O binary)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.327439385" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.327439385" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/HK32F030}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1188616997" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/> <builder buildPath="${workspace_loc:/HK32F030}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1188616997" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.420244661" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler"> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.420244661" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">

View File

@ -60,7 +60,7 @@ void btn_tick()
} else if (btn[i].hold_thresh && (btn[i].held >> BTN_HOLD_SHIFT) >= btn[i].hold_thresh) { } else if (btn[i].hold_thresh && (btn[i].held >> BTN_HOLD_SHIFT) >= btn[i].hold_thresh) {
// yes, held, but only set if we didn't already // yes, held, but only set if we didn't already
if (!(btn[i].state & BTN_HELD)) { if (!(btn[i].state & BTN_HELD)) {
btn[i].state = BTN_HELD; btn[i].state |= BTN_HELD;
} else if (btn[i].hold_retrig) { } else if (btn[i].hold_retrig) {
// retrigger counter // retrigger counter
btn[i].hold_rt_ctr++; btn[i].hold_rt_ctr++;
@ -102,7 +102,7 @@ void btn_callback()
} }
} }
if ((s & BTN_HELDRT) && !(s & BTN_HELD_CB)) { if ((s & BTN_HELDRT) && !(s & BTN_HELDRT_CB)) {
btn[i].state |= BTN_HELDRT_CB; btn[i].state |= BTN_HELDRT_CB;
if (btn[i].held_cb) { if (btn[i].held_cb) {
btn[i].held_cb(i); btn[i].held_cb(i);

View File

@ -89,11 +89,17 @@ void ledprog_btn_push_cb(uint8_t idx)
if (!prog_mode) return; if (!prog_mode) return;
switch (idx) { switch (idx) {
case BTN_MODE: { case BTN_MODE: { // back or down
if (!uconf.led[led_prog_active][prog_idx]) {
uconf.led[led_prog_active][prog_idx] = 0xff;
} else {
uconf.led[led_prog_active][prog_idx]--;
}
break;
} }
case BTN_SET: { case BTN_SET: { // forward or up
uconf.led[led_prog_active][prog_idx]++;
break;
} }
} }
} }
@ -197,13 +203,13 @@ void ledprog_btn()
btn[BTN_MODE].held_cb = ledprog_btn_held_cb; btn[BTN_MODE].held_cb = ledprog_btn_held_cb;
btn[BTN_MODE].release_cb = ledprog_btn_release_cb; btn[BTN_MODE].release_cb = ledprog_btn_release_cb;
btn[BTN_MODE].hold_thresh = BTN_HOLD_1_00S; btn[BTN_MODE].hold_thresh = BTN_HOLD_1_00S;
btn[BTN_MODE].hold_retrig = 10; btn[BTN_MODE].hold_retrig = 16;
btn[BTN_SET].push_cb = ledprog_btn_push_cb; btn[BTN_SET].push_cb = ledprog_btn_push_cb;
btn[BTN_SET].held_cb = ledprog_btn_held_cb; btn[BTN_SET].held_cb = ledprog_btn_held_cb;
btn[BTN_SET].release_cb = ledprog_btn_release_cb; btn[BTN_SET].release_cb = ledprog_btn_release_cb;
btn[BTN_SET].hold_thresh = BTN_HOLD_1_00S; btn[BTN_SET].hold_thresh = BTN_HOLD_1_00S;
btn[BTN_SET].hold_retrig = 10; btn[BTN_SET].hold_retrig = 16;
} }
void ledprog_run() void ledprog_run()