Skip to content

Commit

Permalink
Merge pull request #19 from futurexdesign/Preheat
Browse files Browse the repository at this point in the history
Add ability to start/stop and configurable preheat when starting a cycle
  • Loading branch information
futurexdesign authored May 6, 2023
2 parents 97f2535 + 5a1de62 commit f06ab93
Show file tree
Hide file tree
Showing 25 changed files with 421 additions and 165 deletions.
94 changes: 33 additions & 61 deletions KiwiBoard.emf
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@
{
"parentId": 12,
"type": "analogItem",
"defaultValue": "0",
"defaultValue": "44",
"item": {
"maxValue": 10,
"maxValue": 119,
"offset": 1,
"divisor": 1,
"unitName": "min",
"unitName": "sec",
"step": 1,
"name": "Time",
"variableName": "spin_duration",
Expand Down Expand Up @@ -372,6 +372,27 @@
"staticDataInRAM": false
}
},
{
"parentId": 15,
"type": "analogItem",
"defaultValue": "4",
"item": {
"maxValue": 9,
"offset": 1,
"divisor": 1,
"unitName": "min",
"step": 1,
"name": "Preheat",
"variableName": "MaxPreheat",
"id": 44,
"eepromAddress": 94,
"functionName": "@settings_changed",
"readOnly": false,
"localOnly": false,
"visible": true,
"staticDataInRAM": false
}
},
{
"parentId": 7,
"type": "subMenu",
Expand Down Expand Up @@ -447,19 +468,15 @@
},
{
"parentId": 30,
"type": "analogItem",
"defaultValue": "1",
"type": "boolItem",
"defaultValue": "true",
"item": {
"maxValue": 2000,
"offset": 0,
"divisor": 1,
"unitName": "",
"step": 5,
"name": "PWM Threshold ",
"variableName": "stealthTransition",
"id": 42,
"eepromAddress": 92,
"functionName": "@stealthTransitionChanged",
"naming": "ON_OFF",
"name": "StealthChop",
"variableName": "StealthChop",
"id": 45,
"eepromAddress": 96,
"functionName": "@stealthChopChange",
"readOnly": false,
"localOnly": false,
"visible": true,
Expand Down Expand Up @@ -487,7 +504,7 @@
"codeOptions": {
"embeddedPlatform": "ARDUINO32",
"lastDisplayUuid": "e6342680-6fab-4d1b-ac08-ce8dbfc0974c",
"lastInputUuid": "6dd87e7d-e751-4912-a70d-91793b1d3d87",
"lastInputUuid": "89cd7f70-0457-4884-97c2-0db904ccb0ba",
"lastRemoteUuid": "2c101fec-1f7d-4ff3-8d2b-992ad41e7fcb",
"lastRemoteUuids": [
"2c101fec-1f7d-4ff3-8d2b-992ad41e7fcb"
Expand Down Expand Up @@ -576,51 +593,6 @@
"latestValue": "400",
"subsystem": "DISPLAY"
},
{
"name": "SW_POLLING_MODE",
"latestValue": "SWITCHES_NO_POLLING",
"subsystem": "INPUT"
},
{
"name": "SWITCH_IODEVICE",
"latestValue": "devicePins",
"subsystem": "INPUT"
},
{
"name": "ENCODER_PIN_A",
"latestValue": "ENC1",
"subsystem": "INPUT"
},
{
"name": "ENCODER_PIN_B",
"latestValue": "ENC2",
"subsystem": "INPUT"
},
{
"name": "ENCODER_PIN_OK",
"latestValue": "BUTTON",
"subsystem": "INPUT"
},
{
"name": "ENCODER_BACK_PIN",
"latestValue": "-1",
"subsystem": "INPUT"
},
{
"name": "ENCODER_NEXT_PIN",
"latestValue": "-1",
"subsystem": "INPUT"
},
{
"name": "PULLUP_LOGIC",
"latestValue": "true",
"subsystem": "INPUT"
},
{
"name": "ENCODER_IS_QUARTER_CYCLE",
"latestValue": "false",
"subsystem": "INPUT"
},
{
"name": "ITEM_FONT",
"latestValue": "num:,4",
Expand Down
Binary file modified TMC_calculations.xlsx
Binary file not shown.
Binary file added images/Stop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/blank-widget-50x50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/dry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/heat-widget-50x50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/logo-cutout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Files in this folder are the raw input graphics for the application. All of these ultimately
need to be run through tcMenuDesigner, or otherwise converted to hex to be stored in PROGMEM
- All graphics used by the application must consist of 1 color on a transparent background.
Binary file added images/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/spash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/spin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/wash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions src/EncoderShim.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2023 Kevin Balthaser [email protected]
*/
//

#include "EncoderShim.h"

EncoderShim::EncoderShim() {

}

void EncoderShim::initForEncoder() {

switches.init(internalDigitalIo(), SWITCHES_NO_POLLING, true);

switches.addSwitchListener(BUTTON, this, NO_REPEAT, false);
setupRotaryEncoderWithInterrupt(ENC1, ENC2, this, HWACCEL_NONE, FULL_CYCLE);
}

void EncoderShim::encoderHasChanged(int newValue) {
Serial.println("Encoder Turned");
Serial.println(newValue);

// Which way did the encoder go...
bool direction;
if (newValue < encoderValue) {
direction = false;
} else {
direction = true;
}

encoderValue = newValue;

menuMgr.valueChanged(newValue);
Serial.println("Check for encoderChangeFn");
if (encoderChangeFn != nullptr) {
Serial.println("call encoderChangefn Callback");
encoderChangeFn(direction, false);
}

}

void EncoderShim::onPressed(pinid_t pin, bool held) {
Serial.println("button down");
if (encoderClickFn != nullptr) {
encoderClickFn(false, held);
}
}

void EncoderShim::onReleased(pinid_t pin, bool held) {
Serial.println("button up");
// always send false, since we don't want the normal tcMenu long press reset behavior, and we are acting
// on Pressed long press, not release.
menuMgr.onMenuSelect(false);
}

void EncoderShim::registerChangeCallback(EncoderShimFn callback) {

encoderChangeFn = callback;

}

void EncoderShim::registerClickCallback(EncoderShimFn callback) {

encoderClickFn = callback;

}

/**
* Reinitialize the encoder with a and b pins reversed.
*/
void EncoderShim::invertEncoderDirection() {
setupRotaryEncoderWithInterrupt(ENC2, ENC1, this, HWACCEL_NONE, FULL_CYCLE);
}

61 changes: 61 additions & 0 deletions src/EncoderShim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2023 Kevin Balthaser [email protected]
*
* Create a shim that will sit in between the tcMenu layer, and the firmware. This will allow us to monitor the rotary
* encoder on every cycle to pick up on movement events, and fire any callback events.
*/
//

#include "picoPlatform.h" // Need the platform pin definitions
#include <tcMenu.h>

#ifndef KIWIBOARDFIRMWARE_ENCODERSHIM_H
#define KIWIBOARDFIRMWARE_ENCODERSHIM_H


/** The definition of a callback from EncoderShim object */
typedef void (*EncoderShimFn)(bool direction, bool longPress);

class EncoderShim : EncoderListener, SwitchListener {

public:
EncoderShim();

/**
* Initialize the encoder and button for pins defined in picoPlatform. This must be called
* before setupMenu.
*/
void initForEncoder();

/**
* Register the function that should be called when the encoder value changes.
*/
void registerChangeCallback(EncoderShimFn callback);

/**
* Register the function that should be called when the encoder button has been pressed.
*/
void registerClickCallback(EncoderShimFn callback);

/**
* Swap the two encoder pins, this will invert the direction of the encoder in all modes.
*/
void invertEncoderDirection();

private:
void encoderHasChanged(int newValue) override;

void onPressed(pinid_t pin, bool held) override;

void onReleased(pinid_t pin, bool held) override;

// Callback Functions for click and change
EncoderShimFn encoderChangeFn = nullptr;
EncoderShimFn encoderClickFn = nullptr;

int encoderValue = 0;// last known encoder value

};


#endif //KIWIBOARDFIRMWARE_ENCODERSHIM_H
Loading

0 comments on commit f06ab93

Please sign in to comment.