Initial menu commit

pull/93/head
Drachenkatze 2019-08-11 21:41:55 +02:00
parent 993fdf6809
commit 12528dac1e
20 changed files with 4074 additions and 356 deletions

23
platformio.ini Normal file
View File

@ -0,0 +1,23 @@
;PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
src_dir = printermonitor
[common]
lib_deps = LinkedList@dac3874d28,
KeyPad@3.1.1
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
upload_speed = 2000000
monitor_speed = 115200

View File

@ -0,0 +1,10 @@
#include "Command.h"
Command::Command () {
}
void Command::execute () {
}

7
printermonitor/Command.h Normal file
View File

@ -0,0 +1,7 @@
class Command
{
public:
Command();
void execute (void);
};

View File

@ -0,0 +1,193 @@
#include "Menu.h"
#include "MenuFonts.h"
Menu::Menu()
{
menuItems = LinkedList<MenuItem *>();
}
Menu::Menu(String menuTitle)
{
MenuTitle = menuTitle;
Menu();
}
void Menu::processKey(char c)
{
switch (c)
{
case '0':
doExit();
break;
case '*':
if (startPage > 0)
{
startPage = startPage - 1;
}
break;
case '#':
if (startPage < getMaxPage())
{
startPage++;
}
break;
}
}
void Menu::doExit(void)
{
if (exitCallback != NULL)
{
exitCallback();
}
}
int Menu::getMaxPage()
{
return ceil(menuItems.size() / MENU_MAX_DISPLAY_ITEMS);
}
void Menu::drawMenu(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{
if (displayMillis + MENU_TIMEOUT < millis())
{
doExit();
return;
}
display->setColor(WHITE);
display->setFont((const uint8_t *)ArialMT_Plain_10);
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->fillRect(0, 0, 128, 11);
display->setColor(BLACK);
display->drawString(64, 0, MenuTitle);
display->setColor(WHITE);
display->setTextAlignment(TEXT_ALIGN_LEFT);
bool hasPrevPage = startPage > 0;
bool hasNextPage = true;
int startIndex = startPage * MENU_MAX_DISPLAY_ITEMS;
int endIndex = startIndex + MENU_MAX_DISPLAY_ITEMS;
if (endIndex + startIndex > menuItems.size() - 1)
{
endIndex = menuItems.size();
hasNextPage = false;
}
int xPos = 0;
int yPos = MENU_ITEM_START_POS_Y;
char startKey = '1';
bool isSecondColumn = false;
for (int i = startIndex; i < endIndex; i++)
{
MenuItem *menuItem = menuItems[i];
drawRegularKeyboardButtonIcon(display, xPos, yPos, startKey, false, true);
startKey++;
display->setFont((const uint8_t *)DialogInput_plain_11);
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(xPos + REGULAR_KEYPAD_BUTTON_ICON_WIDTH + 2, yPos - 1, menuItem->ItemName);
if (!isSecondColumn)
{
display->setColor(BLACK);
// Clear string remainder
display->fillRect(xPos + MENU_ITEM_SECOND_COLUMN_START_X, yPos, xPos + MENU_ITEM_SECOND_COLUMN_START_X + MENU_ITEM_SECOND_COLUMN_START_X, yPos + MENU_ITEM_HEIGHT);
display->setColor(WHITE);
}
yPos = yPos + MENU_ITEM_HEIGHT;
if (floor(MENU_MAX_DISPLAY_ITEMS / 2) - 1 == i)
{
isSecondColumn = true;
yPos = MENU_ITEM_START_POS_Y;
xPos = MENU_ITEM_SECOND_COLUMN_START_X;
}
display->fillRect(0, MENU_BOTTOM_BAR_LINE, 128, 64 - MENU_BOTTOM_BAR_LINE + 1);
/* bottomBarStart = 44;
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(ArialMT_Plain_10);
display->setColor(BLACK);
display->drawString(SMALL_KEYPAD_BUTTON_ICON_WIDTH + 1, bottomBarStart - 2, "Enter manually");
//display->drawString(44 + SMALL_KEYPAD_BUTTON_ICON_WIDTH+1, bottomBarStart-1, "Exit");
//display->drawString(88 + SMALL_KEYPAD_BUTTON_ICON_WIDTH+1, bottomBarStart-1, "Next");
drawSmallKeyboardButtonIcon(display, 1, bottomBarStart, '7', true, true);
//drawSmallKeyboardButtonIcon(display, 44, bottomBarStart, '0');
//drawSmallKeyboardButtonIcon(display, 88, bottomBarStart, '#');
*/
int bottomBarStart = 54;
if (hasNextPage)
{
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(ArialMT_Plain_10);
display->setColor(BLACK);
display->drawString(88 + SMALL_KEYPAD_BUTTON_ICON_WIDTH + 1, bottomBarStart - 2, "Next");
drawSmallKeyboardButtonIcon(display, 89, bottomBarStart, '#', true, true);
}
if (hasPrevPage)
{
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(ArialMT_Plain_10);
display->setColor(BLACK);
display->drawString(SMALL_KEYPAD_BUTTON_ICON_WIDTH + 1, bottomBarStart - 2, "Prev");
drawSmallKeyboardButtonIcon(display, 1, bottomBarStart, '*', true, true);
}
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(ArialMT_Plain_10);
display->setColor(BLACK);
display->drawString(44 + SMALL_KEYPAD_BUTTON_ICON_WIDTH + 1, bottomBarStart - 2, "Exit");
drawSmallKeyboardButtonIcon(display, 45, bottomBarStart, '0', true, true);
}
}
void Menu::drawKeyboardButtonIcon(OLEDDisplay *display, int16_t x, int16_t y, char keyButton, const uint8_t *font, int16_t iconWidth, int16_t iconHeight, int16_t xOffset, int16_t yOffset, bool inverted, bool filled)
{
OLEDDISPLAY_COLOR foregroundColor = WHITE;
OLEDDISPLAY_COLOR backgroundColor = BLACK;
if (inverted)
{
foregroundColor = BLACK;
backgroundColor = WHITE;
}
display->setFont(font);
display->setTextAlignment(TEXT_ALIGN_CENTER_BOTH);
display->setColor(foregroundColor);
if (filled)
{
display->fillRect(x, y, iconWidth, iconHeight);
display->setColor(backgroundColor);
}
else
{
display->drawRect(x, y, iconWidth, iconHeight);
}
display->drawString(x + xOffset + iconWidth / 2, y + yOffset + iconHeight / 2, String(keyButton));
display->setColor(WHITE);
}
void Menu::drawRegularKeyboardButtonIcon(OLEDDisplay *display, int16_t x, int16_t y, char keyButton, bool inverted, bool filled)
{
drawKeyboardButtonIcon(display, x, y, keyButton, (const uint8_t *)Open_Sans_ExtraBold_14,
REGULAR_KEYPAD_BUTTON_ICON_WIDTH, REGULAR_KEYPAD_BUTTON_ICON_HEIGHT, REGULAR_KEYPAD_BUTTON_ICON_X_OFFSET, REGULAR_KEYPAD_BUTTON_ICON_Y_OFFSET, inverted, filled);
}
void Menu::drawSmallKeyboardButtonIcon(OLEDDisplay *display, int16_t x, int16_t y, char keyButton, bool inverted, bool filled)
{
drawKeyboardButtonIcon(display, x, y, keyButton, (const uint8_t *)ArialMT_Plain_10,
SMALL_KEYPAD_BUTTON_ICON_WIDTH, SMALL_KEYPAD_BUTTON_ICON_HEIGHT, SMALL_KEYPAD_BUTTON_ICON_X_OFFSET, SMALL_KEYPAD_BUTTON_ICON_Y_OFFSET, inverted, filled);
}

View File

@ -0,0 +1,45 @@
#include <Arduino.h>
#include "MenuItem.h"
#include <LinkedList.h>
#include <OLEDDisplay.h>
#include <OLEDDisplayUi.h>
#define MENU_TIMEOUT 5000
#define MENU_MAX_DISPLAY_ITEMS 4
#define MENU_ITEM_START_POS_Y 14
#define MENU_ITEM_SECOND_COLUMN_START_X 64
#define MENU_ITEM_HEIGHT 14
#define MENU_BOTTOM_BAR_LINE 43
#define REGULAR_KEYPAD_BUTTON_ICON_WIDTH 12
#define REGULAR_KEYPAD_BUTTON_ICON_HEIGHT 12
#define REGULAR_KEYPAD_BUTTON_ICON_X_OFFSET 0
#define REGULAR_KEYPAD_BUTTON_ICON_Y_OFFSET 0
#define SMALL_KEYPAD_BUTTON_ICON_WIDTH 7
#define SMALL_KEYPAD_BUTTON_ICON_HEIGHT 9
#define SMALL_KEYPAD_BUTTON_ICON_X_OFFSET 1
#define SMALL_KEYPAD_BUTTON_ICON_Y_OFFSET 0
class Menu
{
public:
Menu();
Menu(String menuTitle);
String MenuTitle;
void drawMenu(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
void processKey(char c);
int getMaxPage();
void (*exitCallback)(void) = NULL;
int startPage = 0;
LinkedList<MenuItem *> menuItems;
unsigned long displayMillis;
private:
void doExit (void);
void drawRegularKeyboardButtonIcon(OLEDDisplay *display, int16_t x, int16_t y, char keyButton, bool inverted, bool filled);
void drawSmallKeyboardButtonIcon(OLEDDisplay *display, int16_t x, int16_t y, char keyButton, bool inverted, bool filled);
void drawKeyboardButtonIcon(OLEDDisplay *display, int16_t x, int16_t y, char keyButton, const uint8_t *font, int16_t iconWidth, int16_t iconHeight, int16_t xOffset, int16_t yOffset, bool inverted, bool filled);
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
#include <Arduino.h>
#include "MenuItem.h"
MenuItem::MenuItem() {
}
MenuItem::MenuItem(String itemName)
{
ItemName = itemName;
}

View File

@ -0,0 +1,8 @@
#include <Arduino.h>
class MenuItem {
public:
String ItemName;
MenuItem();
MenuItem (String itemName);
};

View File

@ -0,0 +1,9 @@
#include "PreheatMenu.h"
PreheatMenu::PreheatMenu () {
MenuTitle = "Preheat Menu";
}
void PreheatMenu::RetrieveTemperatures () {
}

View File

@ -0,0 +1,7 @@
#include "Menu.h"
class PreheatMenu: public Menu {
public:
PreheatMenu();
void RetrieveTemperatures();
};

View File

@ -0,0 +1,7 @@
#include <Arduino.h>
#include "TemperatureMenuItem.h"
TemperatureMenuItem::TemperatureMenuItem(String itemName)
{
ItemName = itemName;
}

View File

@ -0,0 +1,13 @@
#include "MenuItem.h"
class TemperatureMenuItem : public MenuItem
{
public:
TemperatureMenuItem(String itemName);
int bed;
int chamber;
int extruder;
bool has_bed_temp;
bool has_extruder_temp;
bool has_chamber_temp;
};

View File

@ -27,6 +27,7 @@ SOFTWARE.
#include "OctoPrintClient.h" #include "OctoPrintClient.h"
OctoPrintClient::OctoPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu) { OctoPrintClient::OctoPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu) {
temperaturePresets = LinkedList<TemperaturePreset *>();
updatePrintClient(ApiKey, server, port, user, pass, psu); updatePrintClient(ApiKey, server, port, user, pass, psu);
} }
@ -285,6 +286,53 @@ void OctoPrintClient::getPrinterPsuState() {
} }
} }
void OctoPrintClient::getTemperaturePresets()
{
if (!validate())
{
return;
}
String apiPostData = "GET /api/settings HTTP/1.1";
WiFiClient printClient = getSubmitRequest(apiPostData);
if (printerData.error != "")
{
return;
}
const size_t bufferSize3 = JSON_ARRAY_SIZE(4) + JSON_OBJECT_SIZE(1) + 20 * JSON_OBJECT_SIZE(4) + 245;
DynamicJsonBuffer jsonBuffer3(bufferSize3);
printClient.find("\"temperature\": ");
do
{
JsonObject &root3 = jsonBuffer3.parseObject(printClient);
if (!root3.success())
{
Serial.println("Not succssful");
}
else
{
temperaturePresets.clear();
JsonArray &temperature_profiles = root3["profiles"];
for (int i = 0; i < temperature_profiles.size(); i++)
{
TemperaturePreset *preset = new TemperaturePreset();
preset->bed = temperature_profiles[i]["bed"];
preset->chamber = temperature_profiles[i]["chamber"];
preset->extruder = temperature_profiles[i]["extruder"];
preset->PresetName = temperature_profiles[i]["name"].as<String>();
}
}
} while (printClient.findUntil(",", "]"));
printClient.stop(); //stop client
}
// Reset all PrinterData // Reset all PrinterData
void OctoPrintClient::resetPrintData() { void OctoPrintClient::resetPrintData() {
printerData.averagePrintTime = ""; printerData.averagePrintTime = "";

View File

@ -28,6 +28,8 @@ SOFTWARE.
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include "libs/ArduinoJson/ArduinoJson.h" #include "libs/ArduinoJson/ArduinoJson.h"
#include <base64.h> #include <base64.h>
#include <LinkedList.h>
#include "TemperaturePreset.h"
class OctoPrintClient { class OctoPrintClient {
@ -76,6 +78,9 @@ public:
void getPrinterJobResults(); void getPrinterJobResults();
void getPrinterPsuState(); void getPrinterPsuState();
void updatePrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu); void updatePrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu);
void getTemperaturePresets();
LinkedList<TemperaturePreset *> temperaturePresets;
String getAveragePrintTime(); String getAveragePrintTime();
String getEstimatedPrintTime(); String getEstimatedPrintTime();

View File

@ -49,10 +49,29 @@ SOFTWARE.
#include "OctoPrintClient.h" #include "OctoPrintClient.h"
#include "OpenWeatherMapClient.h" #include "OpenWeatherMapClient.h"
#include "WeatherStationFonts.h" #include "WeatherStationFonts.h"
#include "Menu/MenuFonts.h"
#include "FS.h" #include "FS.h"
#include "SH1106Wire.h" #include "SH1106Wire.h"
#include "SSD1306Wire.h" #include "SSD1306Wire.h"
#include "OLEDDisplayUi.h" #include "OLEDDisplayUi.h"
#include "libs/Keypad_tw/Keypad_tw.h"
#include "Menu/Menu.h"
#define KEYPAD_I2CADDR 0x27 // keypad on PCF8574A
const byte KEYPAD_ROWS = 4; //four rows
const byte KEYPAD_COLS = 4; //three columns
char KEYPAD_KEYS[KEYPAD_ROWS][KEYPAD_COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
// Digitran keypad, bit numbers of PCF8574 i/o port
byte KEYPAD_ROWPINS[KEYPAD_ROWS] = {0, 1, 2, 3}; //connect to the row pinouts of the keypad
byte KEYPAD_COLPINS[KEYPAD_COLS] = {4, 5, 6, 7}; //connect to the column pinouts of the keypad
//****************************** //******************************
// Start Settings // Start Settings
@ -68,7 +87,7 @@ String PrinterAuthUser = ""; // only used if you have haproxy or basic athe
String PrinterAuthPass = ""; // only used with haproxy or basic auth (only needed if you must authenticate) String PrinterAuthPass = ""; // only used with haproxy or basic auth (only needed if you must authenticate)
// Weather Configuration // Weather Configuration
boolean DISPLAYWEATHER = true; // true = show weather when not printing / false = no weather boolean DISPLAYWEATHER = false; // true = show weather when not printing / false = no weather
String WeatherApiKey = ""; // Your API Key from http://openweathermap.org/ String WeatherApiKey = ""; // Your API Key from http://openweathermap.org/
// Default City Location (use http://openweathermap.org/find to find city ID) // Default City Location (use http://openweathermap.org/find to find city ID)
int CityIDs[] = { 5304391 }; //Only USE ONE for weather marquee int CityIDs[] = { 5304391 }; //Only USE ONE for weather marquee
@ -86,7 +105,7 @@ char* www_password = "password"; // Password for the Web Interface
// Date and Time // Date and Time
float UtcOffset = -7; // Hour offset from GMT for your timezone float UtcOffset = -7; // Hour offset from GMT for your timezone
boolean IS_24HOUR = false; // 23:00 millitary 24 hour clock boolean IS_24HOUR = false; // 23:00 millitary 24 hour clock
int minutesBetweenDataRefresh = 15; int minutesBetweenDataRefresh = 1;
boolean DISPLAYCLOCK = true; // true = Show Clock when not printing / false = turn off display when not printing boolean DISPLAYCLOCK = true; // true = Show Clock when not printing / false = turn off display when not printing
// Display Settings // Display Settings
@ -104,7 +123,7 @@ boolean USE_FLASH = true; // true = System LED will Flash on Service Calls; fals
boolean HAS_PSU = false; // Set to true if https://github.com/kantlivelong/OctoPrint-PSUControl/ in use boolean HAS_PSU = false; // Set to true if https://github.com/kantlivelong/OctoPrint-PSUControl/ in use
// OTA Updates // OTA Updates
boolean ENABLE_OTA = true; // this will allow you to load firmware to the device over WiFi (see OTA for ESP8266) boolean ENABLE_OTA = false; // this will allow you to load firmware to the device over WiFi (see OTA for ESP8266)
String OTA_Password = ""; // Set an OTA password here -- leave blank if you don't want to be prompted for password String OTA_Password = ""; // Set an OTA password here -- leave blank if you don't want to be prompted for password
//****************************** //******************************

View File

@ -0,0 +1,5 @@
#include "TemperaturePreset.h"
TemperaturePreset::TemperaturePreset() {
}

View File

@ -0,0 +1,14 @@
#include <Arduino.h>
class TemperaturePreset
{
public:
TemperaturePreset();
String PresetName;
int bed;
int chamber;
int extruder;
bool has_bed_temp;
bool has_extruder_temp;
bool has_chamber_temp;
};

View File

@ -0,0 +1,122 @@
/*
||
|| @file Keypad_tw.h
|| @version 1.0 - Convert Keypad_I2C to use TinyWireM library for ATtiny micros
|| @version 2.0 - PCF8575 support added by Paul Williamson
|| @author G. D. (Joe) Young, ptw
|| @contact "G. D. (Joe) Young" <gdyoung@islandnet.com>
||
|| @description
|| | Keypad_tw provides an interface for using matrix keypads that
|| | are attached with I2C port expanders. It supports multiple keypads,
|| | user selectable pins, and user defined keymaps.
|| |
|| | This version replaces all references to Wire functions (TwoWire) with
|| | their TinyWireM (USI_TWI) equivalents
|| #
||
|| @license
|| | This library is free software; you can redistribute it and/or
|| | modify it under the terms of the GNU Lesser General Public
|| | License as published by the Free Software Foundation; version
|| | 2.1 of the License.
|| |
|| | This library is distributed in the hope that it will be useful,
|| | but WITHOUT ANY WARRANTY; without even the implied warranty of
|| | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|| | Lesser General Public License for more details.
|| |
|| | You should have received a copy of the GNU Lesser General Public
|| | License along with this library; if not, write to the Free Software
|| | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|| #
||
*/
#include "Keypad_tw.h"
// Let the user define a keymap - assume the same row/column count as defined in constructor
void Keypad_tw::begin(char *userKeymap) {
Keypad::begin(userKeymap);
pinState = pinState_set( );
}
// Initialize tw
void Keypad_tw::begin(void) {
// pinState = 0xff;
pinState = pinState_set( );
}
#if 0
// Initialize tw //TinyWireM does not allow re-assigning bus adr
void Keypad_tw::begin(byte address) {
twaddr = address;
USI_TWI::begin(address);
// pinState = 0xff;
pinState = pinState_set( );
}
// Initialize tw
void Keypad_tw::begin(int address) {
twaddr = address;
USI_TWI::begin(address);
// pinState = 0xff;
pinState = pinState_set( );
}
#endif
void Keypad_tw::pin_write(byte pinNum, boolean level) {
word mask = 1<<pinNum;
if( level == HIGH ) {
pinState |= mask;
} else {
pinState &= ~mask;
}
port_write( pinState );
} // twxWrite( )
int Keypad_tw::pin_read(byte pinNum) {
word mask = 0x1<<pinNum;
Wire.requestFrom((int)twaddr, (int)twwidth);
word pinVal = Wire.read( );
if (twwidth > 1) {
pinVal |= Wire.read( ) << 8;
}
pinVal &= mask;
if( pinVal == mask ) {
return 1;
} else {
return 0;
}
}
void Keypad_tw::port_write( word twportval ) {
Wire.beginTransmission((int)twaddr);
Wire.write( twportval & 0x00FF);
if (twwidth > 1) {
Wire.write( twportval >> 8 );
}
Wire.endTransmission();
pinState = twportval;
} // port_write( )
word Keypad_tw::pinState_set( ) {
Wire.requestFrom( (int)twaddr, (int)twwidth );
pinState = Wire.read( );
if (twwidth > 1) {
pinState |= Wire.read( ) << 8;
}
return pinState;
} // set_pinState( )
/*
|| @changelog
|| | 1.0 2015-05-24 - Joe Young : initial conversion from Wire to TinyWireM
|| |
|| | 2.0 2013-08-31 - Paul Williamson : Added i2cwidth parameter for PCF8575 support
|| |
|| | 1.0 2012-07-12 - Joe Young : Initial Release
|| #
*/

View File

@ -0,0 +1,91 @@
/*
||
|| @file Keypad_tw.h
|| @version 1.0 - Convert Keypad_I2C to use TinyWireM library for ATtiny micros
|| @version 2.0 - PCF8575 support added by Paul Williamson
|| @author G. D. (Joe) Young, ptw
|| @contact "G. D. (Joe) Young" <gdyoung@islandnet.com>
||
|| @description
|| | Keypad_tw provides an interface for using matrix keypads that
|| | are attached to I2C port expanders. It supports multiple keypads,
|| | user selectable pins, and user defined keymaps.
|| |
|| | This version replaces all references to Wire functions (TwoWire) with
|| | their TinyWireM (USI_TWI) equivalents
|| #
||
|| @license
|| | This library is free software; you can redistribute it and/or
|| | modify it under the terms of the GNU Lesser General Public
|| | License as published by the Free Software Foundation; version
|| | 2.1 of the License.
|| |
|| | This library is distributed in the hope that it will be useful,
|| | but WITHOUT ANY WARRANTY; without even the implied warranty of
|| | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|| | Lesser General Public License for more details.
|| |
|| | You should have received a copy of the GNU Lesser General Public
|| | License along with this library; if not, write to the Free Software
|| | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|| #
||
*/
#ifndef KEYPAD_tw_H
#define KEYPAD_tw_H
#include "Keypad.h"
#include <Wire.h>
#define PCF8574 1 // PCF8574 I/O expander device is 1 byte wide
#define PCF8574A 1 // PCF8574A I/O expander device is 1 byte wide
#define PCF8575 2 // PCF8575 I/O expander device is 2 bytes wide
class Keypad_tw : public Keypad {
public:
Keypad_tw(char* userKeymap, byte* row, byte* col, byte numRows, byte numCols, byte address, byte width = 1) :
Keypad(userKeymap, row, col, numRows, numCols) { twaddr = address; twwidth = width;}
// Keypad function
void begin(char *userKeymap);
// Wire function
void begin(void);
// Wire function
// void begin(byte address); //TinyWireM does not allow re-assigning bus adr
// Wire function
// void begin(int address);
void pin_mode(byte pinNum, byte mode) {}
void pin_write(byte pinNum, boolean level);
int pin_read(byte pinNum);
// read initial value for pinState
word pinState_set( );
// write a whole byte or word (depending on the port expander chip) to tw port
void port_write( word twportval );
private:
// tw device address
byte twaddr;
// tw port expander device width in bytes (1 for 8574, 2 for 8575)
byte twwidth;
// tw pin_write state persistant storage
// least significant byte is used for 8-bit port expanders
word pinState;
};
#endif // KEYPAD_tw_H
/*
|| @changelog
|| | 1.0 2015-05-24 - Joe Young : initial conversion from Wire to TinyWireM
|| |
|| | 2.0 2013-08-31 - Paul Williamson : Added twwidth parameter for PCF8575 support
|| |
|| | 1.0 2012-07-12 - Joe Young : Initial Release
|| #
*/

File diff suppressed because it is too large Load Diff