Cleanup hardware docs and mostly finalize the calibration jig software setup

This commit is contained in:
KemoNine 2019-06-11 13:01:23 -04:00
parent 18f5226415
commit b3bf34d661
10 changed files with 131 additions and 67 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

View File

@ -0,0 +1,3 @@
# calibration_jig
An Arduino based build that allows testing and reading various sensors (used elsewhere) values for calibration prior to setup with the main dashboards and deployment.

View File

@ -1,5 +1,6 @@
#include <FreeRTOS_SAMD21.h>
#include <semphr.h>
#include <Adafruit_NeoPixel.h>
#include "SPI.h"
#include "Adafruit_GFX.h"
@ -7,13 +8,13 @@
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBold18pt7b.h>
#include <Fonts/FreeMono12pt7b.h>
//FreeMono18pt7b.h
//FreeMono24pt7b.h
//FreeMono9pt7b.h
//FreeMonoBold12pt7b.h
//FreeMonoBold18pt7b.h
//FreeMonoBold24pt7b.h
//FreeMonoBold9pt7b.h
// Various sensors used for calibration data reads
#include <Wire.h>
#include <I2CSoilMoistureSensor.h>
#include "Adafruit_seesaw.h"
Adafruit_seesaw sensor_soil_adafruit;
I2CSoilMoistureSensor sensor_soil_catnip;
// Various tunables
#define ERROR_LED_PIN 13
@ -56,9 +57,11 @@ void TaskLCD(void *pvParameters);
// UI screens
void screenClear();
void screenSoilStemma();
void screenSoilCatnip();
void screenWaterLevelETape();
void screenI2CDIP(bool readValue);
void screenSoilStemma(bool readValue);
void screenSoilCatnip(bool readValue);
void screenWaterLevelETape(bool readValue);
void screenWaterLevelETapeI2C(bool readValue);
// Color conversion (RGB888 -> RGB565 used by Adafruit GFX)
uint16_t RGB565(uint8_t r, uint8_t g, uint8_t b) {
@ -87,6 +90,9 @@ void setup() {
// ; // wait for serial port to connect. Needed for native USB, on LEONARDO, MICRO, YUN, and other 32u4 based boards.
//}
Wire.begin();
pinMode(A0, INPUT);
pixel.begin();
pixel.clear();
pixel.setBrightness(PIXEL_MAX_BRIGHTNESS);
@ -162,7 +168,7 @@ void TaskBlink(void *pvParameters) {
void TaskLCD(void *pvParameters) {
(void) pvParameters;
void (*screens[3])() = {screenSoilStemma, screenSoilCatnip, screenWaterLevelETape};
void (*screens[5])(bool) = {screenI2CDIP, screenSoilStemma, screenSoilCatnip, screenWaterLevelETape, screenWaterLevelETapeI2C};
int current = 0;
while (1) {
@ -176,7 +182,7 @@ void TaskLCD(void *pvParameters) {
if (current >= sizeof(screens) / sizeof(screens[0])) {
current = 0;
}
screens[current]();
screens[current](false);
}
if (xSemaphoreTake(sem_btn_down, 50 / portTICK_PERIOD_MS) == pdPASS) {
screenClear();
@ -188,13 +194,14 @@ void TaskLCD(void *pvParameters) {
if (current < 0) {
current = sizeof(screens) / sizeof(screens[0]) - 1;
}
screens[current]();
screens[current](false);
}
if (xSemaphoreTake(sem_btn_ok, 50 / portTICK_PERIOD_MS) == pdPASS) {
tft.fillRect(tft.width() - 50, 0, 50, 20, RGB565(0, 0, 0));
tft.setFont(&FreeMonoBold9pt7b);
tft.setCursor(tft.width() - 50, 15);
tft.print("OK");
screens[current](true);
}
}
}
@ -216,7 +223,59 @@ void screenClear() {
tft.fillScreen(RGB565(0, 0, 0));
}
void screenSoilStemma() {
void pixelDataReadAlert() {
pixel.setPixelColor(0, pixel.Color(0, 0, 255));
pixel.setBrightness(PIXEL_MAX_BRIGHTNESS);
pixel.show();
}
void screenI2CDIP(bool readValue) {
byte dip_1 = 0;
byte dip_2 = 0;
if (readValue) {
taskENTER_CRITICAL();
pixelDataReadAlert();
screenClear();
Wire.requestFrom(0x65, 2);
// Wait for data to become available -- can be a delayed response due to # of pins to enumerate
while (!Wire.available());
dip_1 = Wire.read();
dip_2 = Wire.read();
taskEXIT_CRITICAL();
}
tft.setFont(&FreeMonoBold18pt7b);
tft.setCursor(0, 25);
tft.println("DIP");
tft.setFont(&FreeMono12pt7b);
tft.println("i2c DIP switch");
tft.println("16 pin");
tft.println("i2c address: 0x65");
tft.println("");
tft.setFont(&FreeMonoBold9pt7b);
tft.println("--Press OK To Read Value--");
tft.println("");
tft.print("DIP 1: ");
tft.println(dip_1, BIN);
tft.print("DIP 2: ");
tft.println(dip_2, BIN);
}
void screenSoilStemma(bool readValue) {
float tempC = 0;
uint16_t capread = 0;
if (readValue) {
taskENTER_CRITICAL();
pixelDataReadAlert();
screenClear();
sensor_soil_adafruit.begin(0x36);
tempC = sensor_soil_adafruit.getTemp();
capread = sensor_soil_adafruit.touchRead(0);
taskEXIT_CRITICAL();
}
tft.setFont(&FreeMonoBold18pt7b);
tft.setCursor(0, 25);
tft.println("Soil");
@ -229,11 +288,27 @@ void screenSoilStemma() {
tft.setFont(&FreeMonoBold9pt7b);
tft.println("--Press OK To Read Value--");
tft.println("");
tft.println("Value: [value]");
tft.print("Temperature: "); tft.print(tempC); tft.println("*C");
tft.print("Capacitive: "); tft.println(capread);
}
void screenSoilCatnip() {
void screenSoilCatnip(bool readValue) {
unsigned int capacitance = 0;
float temp_c = 0;
unsigned int light = 0;
if (readValue) {
taskENTER_CRITICAL();
pixelDataReadAlert();
screenClear();
sensor_soil_catnip.begin();
while (sensor_soil_catnip.isBusy()) delay(50); // available since FW 2.3
capacitance = sensor_soil_catnip.getCapacitance();
temp_c = sensor_soil_catnip.getTemperature() / (float)10;
light = sensor_soil_catnip.getLight(true);
taskEXIT_CRITICAL();
}
tft.setFont(&FreeMonoBold18pt7b);
tft.setCursor(0, 25);
tft.println("Soil");
@ -244,12 +319,22 @@ void screenSoilCatnip() {
tft.setFont(&FreeMonoBold9pt7b);
tft.println("--Press OK To Read Value--");
tft.println("");
tft.println("Capacitance: [value]");
tft.println("Temperature: [value]");
tft.println("Light: [value]");
tft.print("Capacitance: "); tft.println(capacitance);
tft.print("Temperature: "); tft.print(temp_c); tft.println("*C");
tft.print("Light: "); tft.println(light);
}
void screenWaterLevelETape() {
void screenWaterLevelETape(bool readValue) {
float value = 0;
if (readValue) {
taskENTER_CRITICAL();
pixelDataReadAlert();
screenClear();
value = analogRead(A0);
taskEXIT_CRITICAL();
}
tft.setFont(&FreeMonoBold18pt7b);
tft.setCursor(0, 25);
tft.println("Water Level");
@ -260,5 +345,27 @@ void screenWaterLevelETape() {
tft.setFont(&FreeMonoBold9pt7b);
tft.println("--Press OK To Read Value--");
tft.println("");
tft.println("Value: [value]");
tft.print("Value: ");
tft.print(value);
}
void screenWaterLevelETapeI2C(bool readValue) {
if (readValue) {
taskENTER_CRITICAL();
pixelDataReadAlert();
screenClear();
taskEXIT_CRITICAL();
}
tft.setFont(&FreeMonoBold18pt7b);
tft.setCursor(0, 25);
tft.println("Water Level");
tft.setFont(&FreeMono12pt7b);
tft.println("Milone eTape");
tft.println("i2c address: 0x5F");
tft.println("");
tft.setFont(&FreeMonoBold9pt7b);
tft.println("--Press OK To Read Value--");
tft.println("");
tft.println("Value: unknown");
}

View File

@ -4,12 +4,4 @@ A *simple* i2c based dip switch that can be queried as a sensor.
This build uses an ATTiny 2313 / 4313 for the i2c slave with an 8 pin dip switch. The status of all 8 pins on the dip switch are returned via i2c as a single byte that can be used to determine state of all 8.
## Folders
### slave_sender
The main ATTiny code that reads the dip switch states and sends back a single byte with each dip's state encoded as a ```0``` for ```off``` and ```1``` for on.
### master_reader
Sample code used on an Arduino for testing purposes.

View File

@ -1,3 +0,0 @@
# master_reader
Sample code used on an Arduino for testing purposes.

View File

@ -1,32 +0,0 @@
// Wire Master Reader
// by Nicholas Zambetti <http://www.zambetti.com>
// Demonstrates use of the Wire library
// Reads data from an I2C/TWI slave device
// Refer to the "Wire Slave Sender" example for use with this
// Created 29 March 2006
// This example code is in the public domain.
#include <Wire.h>
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(115200); // start serial for output
while (!Serial);
}
void loop() {
Wire.requestFrom(0x65, 2);
// Wait for data to become available -- can be a delayed response due to # of pins to enumerate
while(!Wire.available());
byte dip_1 = Wire.read();
byte dip_2 = Wire.read();
Serial.print("DIP 1: ");
Serial.println(dip_1, BIN);
Serial.print("DIP 2: ");
Serial.println(dip_2, BIN);
delay(500);
}

View File

@ -1,3 +0,0 @@
# slave_sender
The main ATTiny code that reads the dip switch states and sends back a single byte with each dip's state encoded as a ```0``` for ```off``` and ```1``` for on.