application: add segment selector
This commit is contained in:
parent
b531e4cde3
commit
b9df8e7e30
|
@ -673,6 +673,52 @@ static void command_bed_power(void* argument)
|
|||
}
|
||||
}
|
||||
|
||||
/** switch transistors to power to TEC segments
|
||||
* @param[in] argument pointer to unsigned integer: 0 to power all off
|
||||
*/
|
||||
static void command_bed_segment(void* argument)
|
||||
{
|
||||
|
||||
if (argument) { // segment has been provided
|
||||
const int32_t segment = *(int32_t*)argument; // get while segment to turn on/off
|
||||
switch (segment) {
|
||||
case 0: // switch all off
|
||||
gpio_set(GPIO_PORT(MBLK019_CH26_PIN), GPIO_PIN(MBLK019_CH26_PIN));
|
||||
gpio_set(GPIO_PORT(MBLK019_CH14_PIN), GPIO_PIN(MBLK019_CH14_PIN));
|
||||
gpio_set(GPIO_PORT(MBLK019_CH35_PIN), GPIO_PIN(MBLK019_CH35_PIN));
|
||||
break;
|
||||
case 1:
|
||||
gpio_clear(GPIO_PORT(MBLK019_CH26_PIN), GPIO_PIN(MBLK019_CH26_PIN));
|
||||
break;
|
||||
case -1:
|
||||
gpio_set(GPIO_PORT(MBLK019_CH26_PIN), GPIO_PIN(MBLK019_CH26_PIN));
|
||||
break;
|
||||
case 2:
|
||||
gpio_clear(GPIO_PORT(MBLK019_CH14_PIN), GPIO_PIN(MBLK019_CH14_PIN));
|
||||
break;
|
||||
case -2:
|
||||
gpio_set(GPIO_PORT(MBLK019_CH14_PIN), GPIO_PIN(MBLK019_CH14_PIN));
|
||||
break;
|
||||
case 3:
|
||||
gpio_clear(GPIO_PORT(MBLK019_CH35_PIN), GPIO_PIN(MBLK019_CH35_PIN));
|
||||
break;
|
||||
case -3:
|
||||
gpio_set(GPIO_PORT(MBLK019_CH35_PIN), GPIO_PIN(MBLK019_CH35_PIN));
|
||||
break;
|
||||
default:
|
||||
printf("unknown segment: %d\n", segment);
|
||||
break;
|
||||
}
|
||||
sleep_ms(1); // wait to take effect
|
||||
}
|
||||
|
||||
// print segment status
|
||||
printf("CH26: %s CH14: %s CH35: %s\n", \
|
||||
gpio_get(GPIO_PORT(MBLK019_CH26_PIN), GPIO_PIN(MBLK019_CH26_PIN)) ? "off" : "on", \
|
||||
gpio_get(GPIO_PORT(MBLK019_CH14_PIN), GPIO_PIN(MBLK019_CH14_PIN)) ? "off" : "on", \
|
||||
gpio_get(GPIO_PORT(MBLK019_CH35_PIN), GPIO_PIN(MBLK019_CH35_PIN)) ? "off" : "on");
|
||||
}
|
||||
|
||||
/** switch power to lid heater
|
||||
* @param[in] argument pointer to unsigned integer: 0 to power off, 1 to power on
|
||||
*/
|
||||
|
@ -780,6 +826,14 @@ static const struct menu_command_t menu_commands[] = {
|
|||
.argument_description = "[+-temp]",
|
||||
.command_handler = &command_bed_power,
|
||||
},
|
||||
{
|
||||
.shortcut = 's',
|
||||
.name = "segment",
|
||||
.command_description = "TEC segment configuration",
|
||||
.argument = MENU_ARGUMENT_SIGNED,
|
||||
.argument_description = "[+-0,1,2,3]",
|
||||
.command_handler = &command_bed_segment,
|
||||
},
|
||||
{
|
||||
.shortcut = 'L',
|
||||
.name = "lid_power",
|
||||
|
|
Loading…
Reference in New Issue