/*
** Note:
** This was my first Wokwi excursion. I do continue it since my experiment
** with MicroPython failed. The trial was https://wokwi.com/projects/475845604237478913
*/
// Voyager in a Tin (working title)
// This is first of a kind in several aspects:
// - it's my first IoT project
// - it's my first attempt to use Wokwi
// - it's the first clone of an ancient HP Voyager pocket calculator with WiFi
// - it's the first ancient HP pocket calculator build into an Altoids tin
// The Voyager series includes also the since decades well known HP12C Financial Calculator
// The nudge:
// I was triggered to start this project by the ATS Mini Radio and its wireless features,
// see ... esp32-si4732.github.io/ats-mini/index.html
// The goal:
// Since long I'm interessted in "emulators" (which in fact are simulations) of HP pocket calculators.
// Besides those running under Windows, Linux, MacOS, ..., there exist also some clones, but up to now
// none using WiFi. With it I'd like to enable copy and paste, access to data and programs (R/W and R/O),
// exchange of the calculator's ROM (what means changing the model), maybe also version updates.
// This project includes help/suggestions/code from
// - Koepel, working wiring of the display
// - AnonEngineering, wiring of the TCA8418 chip
// - Maverick, simulation of the TCA8418
// - robinblood created with AI support an HP10C simulator
// see https://wokwi.com/projects/476496384464737281
// New role model: youtu.be/xNvaoZqZ404
// Result: lid and box indication swapped in the wiring sketch.
// Note: The included CSV files contain the f/w of the original calculators. Almost at least,
// -- the hp16p is patched to fix the CHS/stack-lift bug.
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <Adafruit_TCA8418.h>
Adafruit_TCA8418 keypad;
#define TFT_DC D4 // D2
#define TFT_CS D1 // D1
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup() {
Wire.begin(D2, D3);
Serial.begin(115200);
while (!Serial) {
delay(10);
}
Serial.println("");
Serial.println("Hello, XIAO ESP32-C6!");
Serial.println("Welcome to Wokwi :-)");
if (! keypad.begin(TCA8418_DEFAULT_ADDR, &Wire)) {
Serial.println("keypad not found, check wiring & pullups!");
while (1);
}
// configure the size of the keypad matrix.
// all other pins will be inputs
keypad.matrix(4, 10);
// flush the internal buffer
keypad.flush();
tft.begin();
tft.setRotation(1);
// test of possible layout, goal: show 4-level stack plus LastX register
tft.setCursor(6, 1);
tft.setTextSize(4);
tft.setTextColor(ILI9341_DARKGREY);
tft.println("-3,141592654");
tft.setCursor(6, 46);
tft.println(" 0,318309886");
tft.setCursor(6, 91);
tft.setTextColor(ILI9341_LIGHTGREY);
tft.println(" 2,718281828");
tft.setCursor(6, 143);
tft.setTextColor(ILI9341_WHITE);
tft.println(" 1,648721271");
tft.setCursor(6, 209);
tft.setTextColor(ILI9341_LIGHTGREY);
tft.print("-0,518309886");
tft.setCursor(1, 188);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(1);
tft.println("USER f g BEGIN GRAD D.MY C PRGM");
}
void loop() {
if (keypad.available() > 0)
{
// datasheet page 15 - Table 1
int k = keypad.getEvent();
if (k & 0x80) Serial.print("PRESS\tR: ");
else Serial.print("RELEASE\tR: ");
k &= 0x7F;
k--;
Serial.print(k / 10);
Serial.print("\tC: ");
Serial.print(k % 10);
Serial.println();
}
}
Loading
xiao-esp32-c6
xiao-esp32-c6
Box
Lid
Box
Lid