~toykeeper/flashlight-firmware/fsm

« back to all changes in this revision

Viewing changes to ToyKeeper/hwdef-noctigon-dm11-boost.c

  • Committer: Selene ToyKeeper
  • Date: 2023-07-23 00:08:12 UTC
  • mto: (483.1.175 anduril2)
  • mto: This revision was merged to the branch mainline in revision 491.
  • Revision ID: bzr@toykeeper.net-20230723000812-lae16ybrvfm1lvlf
converted noctigon-dm11-* builds to multi-channel
(but I could only test dm11-boost on actual hardware)
(also, it looks like dm11-sbt90 is almost identical to the base kr4 build,
 so I removed its hwdef)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
#include "chan-rgbaux.c"
8
8
 
 
9
void set_level_main(uint8_t level);
 
10
bool gradual_tick_main(uint8_t gt);
 
11
 
 
12
 
 
13
Channel channels[] = {
 
14
    { // channel 1 only
 
15
        .set_level    = set_level_main,
 
16
        .gradual_tick = gradual_tick_main
 
17
    },
 
18
    RGB_AUX_CHANNELS
 
19
};
 
20
 
 
21
 
9
22
// single set of LEDs with single power channel, boost
10
23
void set_level_main(uint8_t level) {
11
24
    if (level == 0) {
12
25
        CH1_PWM = 0;
13
26
        PWM_CNT = 0;  // reset phase
14
 
        LED_ENABLE_PORT  &= ~(1 << LED_ENABLE_PIN );  // disable opamp
15
 
        LED_ENABLE_PORT2 &= ~(1 << LED_ENABLE_PIN2);  // disable PMIC
 
27
        CH1_ENABLE_PORT  &= ~(1 << CH1_ENABLE_PIN );  // disable opamp
 
28
        CH1_ENABLE_PORT2 &= ~(1 << CH1_ENABLE_PIN2);  // disable PMIC
16
29
        return;
17
30
    }
18
31
 
19
 
    LED_ENABLE_PORT  |= (1 << LED_ENABLE_PIN );  // enable opamp
20
 
    LED_ENABLE_PORT2 |= (1 << LED_ENABLE_PIN2);  // enable PMIC
 
32
    CH1_ENABLE_PORT  |= (1 << CH1_ENABLE_PIN );  // enable opamp
 
33
    CH1_ENABLE_PORT2 |= (1 << CH1_ENABLE_PIN2);  // enable PMIC
21
34
 
22
35
    level --;  // PWM array index = level - 1
23
36
    PWM_DATATYPE ch1_pwm = PWM_GET(pwm1_levels, level);