cad design

This commit is contained in:
2021-08-30 10:22:20 +02:00
parent c8d9052bcf
commit ddc6f271e8
15 changed files with 54977 additions and 94 deletions

Binary file not shown.

BIN
CAD/3D/LCD.SLDPRT Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

46118
CAD/3D/OUTPUT/case.STL Normal file

File diff suppressed because it is too large Load Diff

BIN
CAD/3D/PSU_5V.SLDPRT Normal file

Binary file not shown.

BIN
CAD/3D/SSR40.SLDPRT Normal file

Binary file not shown.

Binary file not shown.

BIN
CAD/3D/case.SLDPRT Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -1,39 +0,0 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

View File

@@ -1,47 +0,0 @@
// See SetupX_Template.h for all options available
#define SSD1351_DRIVER
#define TFT_WIDTH 128
#define TFT_HEIGHT 128
#define STM32
#define TFT_SPI_PORT 1
#define SSD1351_1DOT5_INCH_128 // For 128 x 128 display
// Wiring:
// +-------------+------------+-------------------------------------------------------------------+
// | Display PCB | TFT_eSPI | Info |
// +-------------+------------+-------------------------------------------------------------------+
// | GND | GND (0V) | Common |
// | VCC | 5V or 3.3V | Better to power with 5V if display PCB supports it |
// | DIN | TFT_MOSI | SPI data |
// | SCK | TFT_SCLK | SPI clock |
// | DC | TFT_DC | Distinguish between a command or its data |
// | RST | TFT_RST | Hardware reset, can connect to MCU RST pin as well |
// | CS | TFT_CS | Chip select, Set to -1 if for manually use with multiple displays |
// +-------------+------------+-------------------------------------------------------------------+
//#define TFT_MOSI PA7
//#define TFT_SCLK PA5
#define TFT_DC PB1
#define TFT_RST PA12
#define TFT_CS PB0
#define LOAD_GLCD // Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2 // Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4 // Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6 // Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7 // 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
#define LOAD_FONT8 // Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
//#define LOAD_FONT8N // Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF // FreeFonts- 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
#define SMOOTH_FONT
#define SPI_FREQUENCY 20000000
//#define SPI_FREQUENCY 40000000 // Works after shielding the wires!

View File

@@ -0,0 +1,266 @@
#include "ft6206_touch.h"
/**************************************************************************/
/*!
@brief Instantiates a new FT6206 class
*/
/**************************************************************************/
// I2C, no address adjustments or pins
FT6206::FT6206() { touches = 0; }
/**************************************************************************/
/*!
@brief Setups the I2C interface and hardware, identifies if chip is found
@param thresh Optional threshhold-for-touch value, default is
FT6206_DEFAULT_THRESSHOLD but you can try changing it if your screen is
too/not sensitive.
@returns True if an FT6206 is found, false on any failure
*/
/**************************************************************************/
bool FT6206::begin(uint8_t thresh) {
Wire.begin();
#ifdef FT6206_DEBUG
Serial.print("Vend ID: 0x");
Serial.println(readRegister8(FT62XX_REG_VENDID), HEX);
Serial.print("Chip ID: 0x");
Serial.println(readRegister8(FT62XX_REG_CHIPID), HEX);
Serial.print("Firm V: ");
Serial.println(readRegister8(FT62XX_REG_FIRMVERS));
Serial.print("Point Rate Hz: ");
Serial.println(readRegister8(FT62XX_REG_POINTRATE));
Serial.print("Thresh: ");
Serial.println(readRegister8(FT62XX_REG_THRESHHOLD));
// dump all registers
for (int16_t i = 0; i < 0x10; i++) {
Serial.print("I2C $");
Serial.print(i, HEX);
Serial.print(" = 0x");
Serial.println(readRegister8(i), HEX);
}
#endif
// change threshhold to be higher/lower
writeRegister8(FT62XX_REG_THRESHHOLD, thresh);
if (readRegister8(FT62XX_REG_VENDID) != FT62XX_VENDID) {
return false;
}
uint8_t id = readRegister8(FT62XX_REG_CHIPID);
if ((id != FT6206_CHIPID) && (id != FT6236_CHIPID) &&
(id != FT6236U_CHIPID)) {
return false;
}
return true;
}
/**************************************************************************/
/*!
@brief Determines if there are any touches detected
@returns Number of touches detected, can be 0, 1 or 2
*/
/**************************************************************************/
uint8_t FT6206::touched(void) {
uint8_t n = readRegister8(FT62XX_REG_NUMTOUCHES);
if (n > 2) {
n = 0;
}
return n;
}
/**************************************************************************/
/*!
@brief Queries the chip and retrieves a point data
@param n The # index (0 or 1) to the points we can detect. In theory we can
detect 2 points but we've found that you should only use this for
single-touch since the two points cant share the same half of the screen.
@returns {@link TS_Point} object that has the x and y coordinets set. If the
z coordinate is 0 it means the point is not touched. If z is 1, it is
currently touched.
*/
/**************************************************************************/
TS_Point FT6206::getPoint(uint8_t n) {
readData();
if ((touches == 0) || (n > 1)) {
return TS_Point(0, 0, 0);
} else {
return TS_Point(touchX[n], touchY[n], 1);
}
}
/************ lower level i/o **************/
/**************************************************************************/
/*!
@brief Reads the bulk of data from captouch chip. Fill in {@link touches},
{@link touchX}, {@link touchY} and {@link touchID} with results
*/
/**************************************************************************/
void FT6206::readData(void) {
uint8_t i2cdat[16];
Wire.beginTransmission(FT62XX_ADDR);
Wire.write((byte)0);
Wire.endTransmission();
Wire.requestFrom((byte)FT62XX_ADDR, (byte)16);
for (uint8_t i = 0; i < 16; i++)
i2cdat[i] = Wire.read();
#ifdef FT6206_DEBUG
for (int16_t i = 0; i < 16; i++) {
Serial.print("I2C $");
Serial.print(i, HEX);
Serial.print(" = 0x");
Serial.println(i2cdat[i], HEX);
}
#endif
touches = i2cdat[0x02];
if ((touches > 2) || (touches == 0)) {
touches = 0;
}
#ifdef FT6206_DEBUG
Serial.print("# Touches: ");
Serial.println(touches);
for (uint8_t i = 0; i < 16; i++) {
Serial.print("0x");
Serial.print(i2cdat[i], HEX);
Serial.print(" ");
}
Serial.println();
if (i2cdat[0x01] != 0x00) {
Serial.print("Gesture #");
Serial.println(i2cdat[0x01]);
}
#endif
for (uint8_t i = 0; i < 2; i++) {
touchX[i] = i2cdat[0x03 + i * 6] & 0x0F;
touchX[i] <<= 8;
touchX[i] |= i2cdat[0x04 + i * 6];
touchY[i] = i2cdat[0x05 + i * 6] & 0x0F;
touchY[i] <<= 8;
touchY[i] |= i2cdat[0x06 + i * 6];
touchID[i] = i2cdat[0x05 + i * 6] >> 4;
}
#ifdef FT6206_DEBUG
Serial.println();
for (uint8_t i = 0; i < touches; i++) {
Serial.print("ID #");
Serial.print(touchID[i]);
Serial.print("\t(");
Serial.print(touchX[i]);
Serial.print(", ");
Serial.print(touchY[i]);
Serial.print(") ");
}
Serial.println();
#endif
}
uint8_t FT6206::readRegister8(uint8_t reg) {
uint8_t x;
// use i2c
Wire.beginTransmission(FT62XX_ADDR);
Wire.write((byte)reg);
Wire.endTransmission();
Wire.requestFrom((byte)FT62XX_ADDR, (byte)1);
x = Wire.read();
#ifdef I2C_DEBUG
Serial.print("$");
Serial.print(reg, HEX);
Serial.print(": 0x");
Serial.println(x, HEX);
#endif
return x;
}
void FT6206::writeRegister8(uint8_t reg, uint8_t val) {
// use i2c
Wire.beginTransmission(FT62XX_ADDR);
Wire.write((byte)reg);
Wire.write((byte)val);
Wire.endTransmission();
}
/*
// DONT DO THIS - REALLY - IT DOESNT WORK
void FT6206::autoCalibrate(void) {
writeRegister8(FT06_REG_MODE, FT6206_REG_FACTORYMODE);
delay(100);
//Serial.println("Calibrating...");
writeRegister8(FT6206_REG_CALIBRATE, 4);
delay(300);
for (uint8_t i = 0; i < 100; i++) {
uint8_t temp;
temp = readRegister8(FT6206_REG_MODE);
Serial.println(temp, HEX);
//return to normal mode, calibration finish
if (0x0 == ((temp & 0x70) >> 4))
break;
}
delay(200);
//Serial.println("Calibrated");
delay(300);
writeRegister8(FT6206_REG_MODE, FT6206_REG_FACTORYMODE);
delay(100);
writeRegister8(FT6206_REG_CALIBRATE, 5);
delay(300);
writeRegister8(FT6206_REG_MODE, FT6206_REG_WORKMODE);
delay(300);
}
*/
/****************/
/**************************************************************************/
/*!
@brief Instantiates a new FT6206 class with x, y and z set to 0 by default
*/
/**************************************************************************/
TS_Point::TS_Point(void) { x = y = z = 0; }
/**************************************************************************/
/*!
@brief Instantiates a new FT6206 class with x, y and z set by params.
@param _x The X coordinate
@param _y The Y coordinate
@param _z The Z coordinate
*/
/**************************************************************************/
TS_Point::TS_Point(int16_t _x, int16_t _y, int16_t _z) {
x = _x;
y = _y;
z = _z;
}
/**************************************************************************/
/*!
@brief Simple == comparator for two TS_Point objects
@returns True if x, y and z are the same for both points, False otherwise.
*/
/**************************************************************************/
bool TS_Point::operator==(TS_Point p1) {
return ((p1.x == x) && (p1.y == y) && (p1.z == z));
}
/**************************************************************************/
/*!
@brief Simple != comparator for two TS_Point objects
@returns False if x, y and z are the same for both points, True otherwise.
*/
/**************************************************************************/
bool TS_Point::operator!=(TS_Point p1) {
return ((p1.x != x) || (p1.y != y) || (p1.z != z));
}

View File

@@ -0,0 +1,72 @@
#pragma once
#include "Arduino.h"
#include <Wire.h>
#define FT62XX_ADDR 0x38 //!< I2C address
#define FT62XX_G_FT5201ID 0xA8 //!< FocalTech's panel ID
#define FT62XX_REG_NUMTOUCHES 0x02 //!< Number of touch points
#define FT62XX_NUM_X 0x33 //!< Touch X position
#define FT62XX_NUM_Y 0x34 //!< Touch Y position
#define FT62XX_REG_MODE 0x00 //!< Device mode, either WORKING or FACTORY
#define FT62XX_REG_CALIBRATE 0x02 //!< Calibrate mode
#define FT62XX_REG_WORKMODE 0x00 //!< Work mode
#define FT62XX_REG_FACTORYMODE 0x40 //!< Factory mode
#define FT62XX_REG_THRESHHOLD 0x80 //!< Threshold for touch detection
#define FT62XX_REG_POINTRATE 0x88 //!< Point rate
#define FT62XX_REG_FIRMVERS 0xA6 //!< Firmware version
#define FT62XX_REG_CHIPID 0xA3 //!< Chip selecting
#define FT62XX_REG_VENDID 0xA8 //!< FocalTech's panel ID
#define FT62XX_VENDID 0x11 //!< FocalTech's panel ID
#define FT6206_CHIPID 0x06 //!< Chip selecting
#define FT6236_CHIPID 0x36 //!< Chip selecting
#define FT6236U_CHIPID 0x64 //!< Chip selecting
// calibrated for Adafruit 2.8" ctp screen
#define FT62XX_DEFAULT_THRESHOLD 128 //!< Default threshold for touch detection
/**************************************************************************/
/*!
@brief Helper class that stores a TouchScreen Point with x, y, and z
coordinates, for easy math/comparison
*/
/**************************************************************************/
class TS_Point {
public:
TS_Point(void);
TS_Point(int16_t x, int16_t y, int16_t z);
bool operator==(TS_Point);
bool operator!=(TS_Point);
int16_t x; /*!< X coordinate */
int16_t y; /*!< Y coordinate */
int16_t z; /*!< Z coordinate (often used for pressure) */
};
/**************************************************************************/
/*!
@brief Class that stores state and functions for interacting with FT6206
capacitive touch chips
*/
/**************************************************************************/
class FT6206 {
public:
FT6206(void);
bool begin(uint8_t thresh = FT62XX_DEFAULT_THRESHOLD);
uint8_t touched(void);
TS_Point getPoint(uint8_t n = 0);
// void autoCalibrate(void);
private:
void writeRegister8(uint8_t reg, uint8_t val);
uint8_t readRegister8(uint8_t reg);
void readData(void);
uint8_t touches;
uint16_t touchX[2], touchY[2], touchID[2];
};

View File

@@ -15,10 +15,12 @@ framework = arduino
upload_protocol = stlink upload_protocol = stlink
debug_tool = stlink debug_tool = stlink
monitor_speed = 115200 monitor_speed = 115200
monitor_port = /dev/cu.usbmodem3474359635391
lib_deps = lib_deps =
bodmer/TFT_eSPI@^2.3.70 bodmer/TFT_eSPI@^2.3.70
br3ttb/PID@^1.2.1 br3ttb/PID@^1.2.1
robtillaart/MAX31855@^0.2.5 robtillaart/MAX31855@^0.2.5
;adafruit/Adafruit FT6206 Library@^1.0.6
lib_ldf_mode = deep+ lib_ldf_mode = deep+
build_flags = build_flags =
-D USER_SETUP_LOADED=1 -D USER_SETUP_LOADED=1

View File

@@ -6,6 +6,9 @@
#include <vector> #include <vector>
#include <TFT_eSPI.h> // Include the graphics library #include <TFT_eSPI.h> // Include the graphics library
#include "ft6206_touch.h"
FT6206 ts = FT6206();
TFT_eSPI tft = TFT_eSPI(); // Create object "tft" TFT_eSPI tft = TFT_eSPI(); // Create object "tft"
TFT_eSprite looptime_spr = TFT_eSprite(&tft); TFT_eSprite looptime_spr = TFT_eSprite(&tft);
@@ -65,7 +68,7 @@ uint32_t lastReading = 0;
void updateRealtimeGraph(void) void updateRealtimeGraph(void)
{ {
if(getReflowStatus() == REFLOW_STATUS_OFF) if (getReflowStatus() == REFLOW_STATUS_OFF)
{ {
temperatureReading.clear(); temperatureReading.clear();
return; return;
@@ -86,10 +89,10 @@ void updateRealtimeGraph(void)
{ {
uint32_t nowX = calcTime(timeIndex * TEMPINTERVAL); uint32_t nowX = calcTime(timeIndex * TEMPINTERVAL);
uint32_t nowY = calcTemp(sample); uint32_t nowY = calcTemp(sample);
chartArea_spr.drawLine(lastX,lastY, nowX, nowY, CHART_ACTUAL_COLOR); chartArea_spr.drawLine(lastX, lastY, nowX, nowY, CHART_ACTUAL_COLOR);
lastX = nowX; lastX = nowX;
lastY = nowY; lastY = nowY;
timeIndex ++; timeIndex++;
} }
} }
@@ -151,7 +154,7 @@ void prepTargetChart(void)
void updateReflowState(void) void updateReflowState(void)
{ {
uint32_t statusColor = STATE_BG_COLOR; uint32_t statusColor = STATE_BG_COLOR;
if(getOverheating()) if (getOverheating())
{ {
statusColor = TFT_RED; statusColor = TFT_RED;
} }
@@ -208,7 +211,7 @@ void prepChart(void)
for (int i = 0; i < CHART_Y_TICKS; i++) for (int i = 0; i < CHART_Y_TICKS; i++)
{ {
//tick value //tick value
uint16_t y_tick_step = calcTempY( tickIndex * (i +1));//CHART_TEMP_MAX - ((CHART_TEMP_MAX - CHART_TEMP_MIN) / CHART_Y_TICKS * i + 1) + CHART_TEMP_MIN; uint16_t y_tick_step = calcTempY(tickIndex * (i + 1)); //CHART_TEMP_MAX - ((CHART_TEMP_MAX - CHART_TEMP_MIN) / CHART_Y_TICKS * i + 1) + CHART_TEMP_MIN;
chartYaxis_spr.drawLine(CHART_Y_AXIS_OFFSET - 8, tickIndex * (i + 1), CHART_Y_AXIS_OFFSET, tickIndex * (i + 1), CHART_LINE_COLOR); chartYaxis_spr.drawLine(CHART_Y_AXIS_OFFSET - 8, tickIndex * (i + 1), CHART_Y_AXIS_OFFSET, tickIndex * (i + 1), CHART_LINE_COLOR);
chartYaxis_spr.setTextDatum(BR_DATUM); chartYaxis_spr.setTextDatum(BR_DATUM);
chartYaxis_spr.drawString(String(y_tick_step), CHART_Y_AXIS_OFFSET - 3, tickIndex * (i + 1), CHART_FONT); chartYaxis_spr.drawString(String(y_tick_step), CHART_Y_AXIS_OFFSET - 3, tickIndex * (i + 1), CHART_FONT);
@@ -304,7 +307,13 @@ void updateGUIButtons(void)
if (timeNow - lastButtonTime > BUTTON_INTERVAL) if (timeNow - lastButtonTime > BUTTON_INTERVAL)
{ {
uint16_t t_x = 0, t_y = 0; // To store the touch coordinates uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
bool pressed = tft.getTouch(&t_x, &t_y); bool pressed = ts.touched(); //.getTouch(&t_x, &t_y);
if (pressed)
{
TS_Point p = ts.getPoint();
t_x = p.x;
t_y = p.y;
}
for (uint8_t b = 0; b < BUTTONS_N; b++) for (uint8_t b = 0; b < BUTTONS_N; b++)
{ {
@@ -344,9 +353,23 @@ void updateGUIButtons(void)
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Setup // Setup
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void initTouchScreen(void)
{
ts.begin();
if (!ts.begin(40))
{
Serial.println("Unable to start touchscreen.");
}
else
{
Serial.println("Touchscreen started.");
}
}
void initLCD(void) void initLCD(void)
{ {
tft.init(); tft.init();
tft.setRotation(2); tft.setRotation(2);
tft.setTextFont(2); tft.setTextFont(2);
tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
@@ -354,6 +377,8 @@ void initLCD(void)
//touch_calibrate(); //touch_calibrate();
tft.setTouch(calData); tft.setTouch(calData);
initTouchScreen();
prepStatus(); prepStatus();
prepButtons(); prepButtons();
prepChart(); prepChart();
@@ -366,12 +391,12 @@ void initLCD(void)
// Main loop // Main loop
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
uint32_t lastLCDupdate = 0; uint32_t lastLCDupdate = 0;
void handleLCD() void handleLCD()
{ {
updateStatus(); updateStatus();
uint32_t timeNow = millis(); uint32_t timeNow = millis();
if (timeNow - lastLCDupdate > LCD_INTERVAL) if (timeNow - lastLCDupdate > LCD_INTERVAL)
{ {