Skip to content

Instantly share code, notes, and snippets.

@jones2126
jones2126 / gist:90dda87dacecac81c32946fc23300b12
Created March 17, 2024 19:31
Two examples of using the 1.28" TFT LCD and an ESP32. The first example is extremely simple; However it flickers. The second one avoids the flicker by using the sprite function.
// First example - extremely simple
#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
#include <SPI.h>
TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
unsigned long displayWeightLastTime = 0;
unsigned long displayWeightDelay = 1000;
unsigned long currentMillis = 0;
@jones2126
jones2126 / gist:e0f5552eafbd3c9419a99385192b3c08
Created March 11, 2024 21:02
Example of rotating sprites using the TFT_eSPI
/*
Example code for 1.28 inch, 240*240 TFT LCD Display which uses the GC9A01 driver. The code rotates a needle
around a pivot point (think compass needle). Thanks to "Volos Projects" on YouTube.
Original code ref: https://github.com/VolosR/RotateSpritesTutorial/blob/main/RotateSpritesTutorial.ino
YouTube ref: https://www.youtube.com/watch?v=oqBa_ptBmLU
I adapted the example code for my LCD that is 240x240 and used some variables in the process
*/
#include <TFT_eSPI.h>
@jones2126
jones2126 / tfttestwithESP32.ino
Created March 9, 2024 19:33
Using Adafruit Example code for TFT 1.28 inch LCD Display Module Round RGB 240*240 and my 30 pin ESP32
// Credit Adafruit example that comes with the Adafruit_GC9A01A.h library. I only wired my board
// consistent with the pin definitions in lines 31-35 using a ESP32 with 30 pins (i.e. ESP-WROOM-DA Module)
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_GC9A01A.h"
// Define pins for display interface. You'll probably need to edit this for
// your own needs:
@jones2126
jones2126 / gpsurvey.ino
Created February 8, 2024 17:03
Sending lat, lon and altitude data from #BESTPOS and $GPGGA messages to Google Sheet in order to survey a site (i.e. average the position over time) so I have use the 'fix position' statement when configuring my Base RTK GPS that sends correction data.
#include <HardwareSerial.h>
#include <WiFi.h>
#include <HTTPClient.h>
// WiFi credentials
const char* ssid = "Pixel_1";
const char* password = "Taco1234";
// Google_Deployment_ID = "AKfycbwZv_vHVI9Hw67vYj609zprKJmdVEuHyH37Mg3VCzo-2lPU9Zaz-dHLp1P7RRAgSDMb"
const char* googleURLPrefix = "https://script.google.com/macros/s/AKfycbwZv_vHVI9Hw67vYj609zprKJmdVEuHyH37Mg3VCzo-2lPU9Zaz-dHLp1P7RRAgSDMb/exec";
@jones2126
jones2126 / gist:a2045cc7bccf19a880a54732f25a375c
Created January 26, 2024 16:48
Using Google Sheets and ESP32 as a data logger
// below is the code that runs on the ESP32
#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include "DHT.h"
#include <Arduino.h>
@jones2126
jones2126 / gps_odom.py
Last active November 24, 2022 21:19
ROS Ag python program to convert from lat/lon to x/y and publish transform between odom and base_link
#!/usr/bin/env python
# gps_odom.py credit Matt Droter
import rospy
import tf
import math
from nav_msgs.msg import Odometry
from tf.transformations import euler_from_quaternion, quaternion_from_euler, quaternion_multiply
from geometry_msgs.msg import Transform, Quaternion, QuaternionStamped, Pose, Point
from sensor_msgs.msg import NavSatFix, NavSatStatus, TimeReference
@jones2126
jones2126 / ttgo_cytron_pid_v3
Last active October 7, 2022 15:57
Used to control a DC steering motor powered by a Cytron MD30C. Currently this is a testing program to determine the PID values. To make that process faster this program reads 3 potentiometers to allow changing the Kp, Ki and Kd values. The current MCU is a TTGO LoRa ESP32 OLED board. The motor is producing a high pitched whining sound. Further r…
/*
* Calculate the error between current direction and the desired direction
* convert the error to a value 0-255 to drive the Cytron motor controller connected to a steering motor.
* Ref: https://www.youtube.com/channel/UCjiVhIvGmRZixSzupD0sS9Q
*
* Thank you Jeff Sampson for guidance and corrections
*/
#include <Arduino.h>
@jones2126
jones2126 / ttgo_cytron_pid_v1
Last active September 29, 2022 16:58
Testing program with PID to control the Cytron MD30
/*
* Calculate the error between current direction and the desired direction
* Use a MAP function to convert the error to a value 0-255
* Use that value to feed into a PID and use the output as the power level for the motor controller
*/
#include <Arduino.h>
/* Credit: https://www.youtube.com/channel/UCjiVhIvGmRZixSzupD0sS9Q
*
* Very hard left - 3492
@jones2126
jones2126 / structure_memcpy_test.ino
Created July 31, 2022 00:16
This was used to confirm the size of the structure and test using the memcpy function to copy from a structure to a buffer and then back again. This helped me clarify this concept would work in anticipation of including it in a LoRa radio master/slave setup.
/*
* This was used to confirm the size of the structure and test using the memcpy function to copy from a structure to a buffer and then back again.
* This helped me clarify this concept would work in anticipation of including it in a lora radio master/slave setup.
*/
struct RadioControlStruct{
int steering_val;
int throttle_val;
float press_norm ;
float press_hg;
float temp;
@jones2126
jones2126 / ttgo_adafruit_client_v2.ino
Last active July 8, 2022 01:54
Testing code for master/tractor/server to interact with slave/remote control/client using a TTGO board and LoRa communication. This code runs on the client which is meant to be a remote control module for the tractor/master.
/* Program: ttgo_adafruit_client_v2.ino
* a simple messaging client (receiver)with the RH_RF95 class.
*/
#include <SPI.h>
#include <RH_RF95.h>
//Libraries for OLED Display
#include <Wire.h>
#include <Adafruit_GFX.h>