aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2020-12-10 18:19:51 +0100
committerKing Kévin <kingkevin@cuvoodoo.info>2020-12-10 18:19:51 +0100
commitb9df8e7e301e5b75e40ed6ea6ef36895dbc46b3e (patch)
tree49a75061b07d20b017965d1435720a45d3cb6198
parentb531e4cde315cb045841c9a82a51b95f8c991b51 (diff)
application: add segment selector
-rw-r--r--application.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/application.c b/application.c
index 6270d6b..9df6f49 100644
--- a/application.c
+++ b/application.c
@@ -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
*/
@@ -781,6 +827,14 @@ static const struct menu_command_t menu_commands[] = {
.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",
.command_description = "set lid power",