Skip to content

Commit

Permalink
Merge pull request #35 from futurexdesign/tcMenu-4-Upgrade
Browse files Browse the repository at this point in the history
tcMenu 4.0 Upgrade.
  • Loading branch information
futurexdesign authored Jun 13, 2023
2 parents 7878a6f + 5c00515 commit fc739c1
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 79 deletions.
111 changes: 73 additions & 38 deletions KiwiBoard.emf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "1.00",
"projectName": "KiwiBoard",
"author": "mtaylor",
"author": "2p3ca",
"items": [
{
"parentId": 0,
Expand Down Expand Up @@ -139,7 +139,7 @@
{
"parentId": 8,
"type": "analogItem",
"defaultValue": "1",
"defaultValue": "6",
"item": {
"maxValue": 10,
"offset": 1,
Expand Down Expand Up @@ -238,9 +238,9 @@
{
"parentId": 12,
"type": "analogItem",
"defaultValue": "50",
"defaultValue": "350",
"item": {
"maxValue": 950,
"maxValue": 650,
"offset": 50,
"divisor": 1,
"unitName": "rpm",
Expand Down Expand Up @@ -398,9 +398,9 @@
"type": "subMenu",
"item": {
"secured": false,
"name": "Advanced",
"variableName": "Advanced",
"id": 30,
"name": "Motor Settings",
"variableName": "MotorSettings",
"id": 52,
"eepromAddress": -1,
"readOnly": false,
"localOnly": false,
Expand All @@ -409,23 +409,24 @@
}
},
{
"parentId": 30,
"parentId": 52,
"type": "boolItem",
"defaultValue": "false",
"item": {
"naming": "YES_NO",
"name": "Invert Encoder",
"variableName": "InvertEncoder",
"id": 34,
"eepromAddress": 79,
"naming": "ON_OFF",
"name": "Motor Test",
"variableName": "motorTest",
"id": 44,
"eepromAddress": -1,
"functionName": "@motortest",
"readOnly": false,
"localOnly": false,
"visible": true,
"staticDataInRAM": false
}
},
{
"parentId": 30,
"parentId": 52,
"type": "analogItem",
"defaultValue": "148",
"item": {
Expand All @@ -446,7 +447,7 @@
}
},
{
"parentId": 30,
"parentId": 52,
"type": "analogItem",
"defaultValue": "17",
"item": {
Expand All @@ -467,7 +468,7 @@
}
},
{
"parentId": 30,
"parentId": 52,
"type": "boolItem",
"defaultValue": "true",
"item": {
Expand All @@ -483,6 +484,57 @@
"staticDataInRAM": false
}
},
{
"parentId": 7,
"type": "subMenu",
"item": {
"secured": false,
"name": "Hardware",
"variableName": "Advanced",
"id": 30,
"eepromAddress": -1,
"readOnly": false,
"localOnly": false,
"visible": true,
"staticDataInRAM": false
}
},
{
"parentId": 30,
"type": "boolItem",
"defaultValue": "false",
"item": {
"naming": "YES_NO",
"name": "Invert Encoder",
"variableName": "InvertEncoder",
"id": 34,
"eepromAddress": 79,
"readOnly": false,
"localOnly": false,
"visible": true,
"staticDataInRAM": false
}
},
{
"parentId": 30,
"type": "enumItem",
"defaultValue": "0",
"item": {
"enumEntries": [
"Full Cycle",
"Quarter Cycle"
],
"name": "Encoder Type",
"variableName": "EncoderType",
"id": 51,
"eepromAddress": 100,
"functionName": "@settings_changed",
"readOnly": false,
"localOnly": false,
"visible": true,
"staticDataInRAM": false
}
},
{
"parentId": 30,
"type": "boolItem",
Expand All @@ -509,7 +561,7 @@
"offset": 0,
"divisor": 1,
"unitName": "%",
"step": 1,
"step": 10,
"name": "Volume",
"variableName": "SoundLevel",
"id": 50,
Expand All @@ -522,24 +574,7 @@
}
},
{
"parentId": 30,
"type": "boolItem",
"defaultValue": "false",
"item": {
"naming": "ON_OFF",
"name": "Motor Test",
"variableName": "motorTest",
"id": 44,
"eepromAddress": -1,
"functionName": "@motortest",
"readOnly": false,
"localOnly": false,
"visible": true,
"staticDataInRAM": false
}
},
{
"parentId": 30,
"parentId": 7,
"type": "textItem",
"defaultValue": "1.00",
"item": {
Expand All @@ -560,7 +595,6 @@
"embeddedPlatform": "ARDUINO32",
"lastDisplayUuid": "e6342680-6fab-4d1b-ac08-ce8dbfc0974c",
"lastInputUuid": "89cd7f70-0457-4884-97c2-0db904ccb0ba",
"lastRemoteUuid": "2c101fec-1f7d-4ff3-8d2b-992ad41e7fcb",
"lastRemoteUuids": [
"2c101fec-1f7d-4ff3-8d2b-992ad41e7fcb"
],
Expand Down Expand Up @@ -685,8 +719,8 @@
}
],
"namingRecursive": false,
"saveToSrc": true,
"useCppMain": true,
"saveLocation": "ALL_TO_SRC",
"usingSizedEEPROMStorage": true,
"eepromDefinition": "eeprom:",
"authenticatorDefinition": "",
Expand All @@ -698,5 +732,6 @@
},
"packageNamespace": "",
"appIsModular": false
}
},
"stringLists": []
}
6 changes: 3 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ board = pico
framework = arduino
board_build.core = earlephilhower
lib_deps =
davetcc/tcMenu@^3.1.0
davetcc/IoAbstraction@^3.1.0
davetcc/tcUnicodeHelper@^0.2.0
davetcc/tcMenu@^4.0.0
davetcc/IoAbstraction@^4.0.0
davetcc/tcUnicodeHelper@^1.0.0
tommag/TMC5160@^1.1.0
bodmer/TFT_eSPI@^2.5.23
bitbank2/PNGdec@^1.0.1
Expand Down
15 changes: 15 additions & 0 deletions src/EncoderShim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ void EncoderShim::registerClickCallback(EncoderShimFn callback) {
* Reinitialize the encoder with a and b pins reversed.
*/
void EncoderShim::invertEncoderDirection() {
reversed = true;
setupRotaryEncoderWithInterrupt(ENC2, ENC1, this, HWACCEL_NONE, FULL_CYCLE);
}

/**
* Set up as a quarter cycle encoder, be careful to not undo any encoder reversing that may of happened
*/
void EncoderShim::setQuarterCycleEncoder() {
if (reversed) {
setupRotaryEncoderWithInterrupt(ENC2, ENC1, this, HWACCEL_NONE, QUARTER_CYCLE);

} else {
setupRotaryEncoderWithInterrupt(ENC1, ENC2, this, HWACCEL_NONE, QUARTER_CYCLE);
}


}

3 changes: 3 additions & 0 deletions src/EncoderShim.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class EncoderShim : EncoderListener, SwitchListener {
*/
void invertEncoderDirection();

void setQuarterCycleEncoder();

private:
void encoderHasChanged(int newValue) override;

Expand All @@ -54,6 +56,7 @@ class EncoderShim : EncoderListener, SwitchListener {
EncoderShimFn encoderClickFn = nullptr;

int encoderValue = 0;// last known encoder value
bool reversed = false;

};

Expand Down
13 changes: 6 additions & 7 deletions src/KiwiBoardFirmware_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "MenuChangeObserver.h"

// Version Number
const char VERSION_NUM[] PROGMEM = "1.2.0";
const char VERSION_NUM[] PROGMEM = "1.2.1";


PicoPlatform *platform;
Expand Down Expand Up @@ -98,6 +98,11 @@ void setup() {
// reinit menu system so encoder is configured properly.
setupMenu();
}
// // If this is not a full cycle encoder, reinit encoder.
// if (menuEncoderType.getCurrentValue() == 1) {
// encoderShim->setQuarterCycleEncoder();
// setupMenu();
// }

// Get saved values for sounder and sound level..
sounderOps->set_menuSound(menusounder.getBoolean());
Expand Down Expand Up @@ -181,12 +186,6 @@ void ui_tick() {
drawable->startDraw();
drawable->drawXBitmap(Coord(135, 0), Coord(50, 50), KiwiLogoWidIcon0);
drawable->endDraw();

drawable = renderer.getDeviceDrawable();
drawable->setColors(RGB(0, 0, 0), RGB(0, 0, 0));
drawable->drawBox(Coord(0, 238), Coord(320,2), true);
drawable->endDraw();

}

// Check for heat icon, if the heater is on, show the icon, otherwise swap in the blank widget
Expand Down
Loading

0 comments on commit fc739c1

Please sign in to comment.