Skip to content

Commit

Permalink
Merge pull request #5 from tgolla/TouchscreenV2
Browse files Browse the repository at this point in the history
Touchscreen Prerelease v1.9
  • Loading branch information
tgolla committed May 28, 2022
2 parents 8e00b4e + 82177cd commit b95cac5
Show file tree
Hide file tree
Showing 26 changed files with 14,995 additions and 517 deletions.
2 changes: 1 addition & 1 deletion .vscode/arduino.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sketch": "SphereBot.ino",
"board": "arduino:avr:mega",
"port": "COM6",
"port": "COM3",
"configuration": "cpu=atmega2560"
}
50 changes: 26 additions & 24 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"cStandard": "c17",
"cppStandard": "c++17",
"defines": [
"USBCON"
"USBCON",
"ARDUINO=10819"
]
},
{
"name": "Arduino",
"compilerPath": "C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\bin\\avr-g++",
"compilerPath": "C:\\Users\\tgoll\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7\\bin\\avr-g++",
"compilerArgs": [
"-w",
"-std=gnu++11",
"-fpermissive",
"-fno-exceptions",
Expand All @@ -39,35 +41,35 @@
],
"intelliSenseMode": "gcc-x64",
"includePath": [
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega",
"C:\\Users\\tgoll\\Documents\\Arduino\\libraries\\Adafruit_Motor_Shield_V2_Library",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src",
"C:\\Users\\tgoll\\Documents\\Arduino\\libraries\\GCodeParser\\src",
"C:\\Users\\tgoll\\Documents\\Arduino\\libraries\\EEPROMTyped\\src",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src",
"C:\\Users\\tgoll\\Documents\\Arduino\\libraries\\Adafruit_GFX_Library",
"C:\\Users\\tgoll\\Documents\\Arduino\\libraries\\Adafruit_ILI9341",
"C:\\Users\\tgoll\\Documents\\Arduino\\libraries\\arduino_705536\\src",
"C:\\Users\\tgoll\\Documents\\Arduino\\libraries\\Adafruit_FT6206_Library",
"C:\\Users\\tgoll\\Documents\\Arduino\\libraries\\Adafruit_ImageReader_Library",
"C:\\Users\\tgoll\\Documents\\Arduino\\libraries\\Adafruit_SPIFlash\\src",
"C:\\Program Files (x86)\\Arduino\\libraries\\Servo\\src",
"C:\\Users\\tgoll\\Documents\\Arduino\\libraries\\Adafruit_BusIO",
"C:\\Users\\tgoll\\Documents\\Arduino\\libraries\\Adafruit_EPD\\src",
"c:\\program files (x86)\\arduino\\hardware\\tools\\avr\\lib\\gcc\\avr\\7.3.0\\include",
"c:\\program files (x86)\\arduino\\hardware\\tools\\avr\\lib\\gcc\\avr\\7.3.0\\include-fixed",
"c:\\program files (x86)\\arduino\\hardware\\tools\\avr\\avr\\include"
"C:\\Users\\tgoll\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.5\\cores\\arduino",
"C:\\Users\\tgoll\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.5\\variants\\mega",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\Adafruit_Motor_Shield_V2_Library",
"C:\\Users\\tgoll\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.5\\libraries\\Wire\\src",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\GCodeParser\\src",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\EEPROMTyped\\src",
"C:\\Users\\tgoll\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.5\\libraries\\EEPROM\\src",
"C:\\Users\\tgoll\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.5\\libraries\\SPI\\src",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\Adafruit_GFX_Library",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\Adafruit_ILI9341",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\SdFat_-_Adafruit_Fork\\src",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\Adafruit_FT6206_Library",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\Adafruit_ImageReader_Library",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\Adafruit_SPIFlash\\src",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\Adafruit_TiCoServo",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\Adafruit_BusIO",
"D:\\Users\\tgoll\\OneDrive - Cimarron Ravine, L.L.C\\Documents\\Arduino\\libraries\\Adafruit_EPD\\src",
"c:\\users\\tgoll\\appdata\\local\\arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7\\lib\\gcc\\avr\\7.3.0\\include",
"c:\\users\\tgoll\\appdata\\local\\arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7\\lib\\gcc\\avr\\7.3.0\\include-fixed",
"c:\\users\\tgoll\\appdata\\local\\arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7\\avr\\include"
],
"forcedInclude": [
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
"C:\\Users\\tgoll\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.5\\cores\\arduino\\Arduino.h"
],
"cStandard": "c11",
"cppStandard": "c++11",
"defines": [
"F_CPU=16000000L",
"ARDUINO=10813",
"ARDUINO=10819",
"ARDUINO_AVR_MEGA2560",
"ARDUINO_ARCH_AVR",
"__DBL_MIN_EXP__=(-125)",
Expand Down
155 changes: 155 additions & 0 deletions AlphabeticSDFileList.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/*
AlphabeticSDFileList.h - Library for listing SD files in a directory on alphabetic order.
Created by Terence F. Golla, April 17, 2022
Released into the public domain.
*/

#include "AlphabeticSDFileList.h"

AlphabeticSDFileList::AlphabeticSDFileList() { }

void AlphabeticSDFileList::Begin(SdFat &SdFat, char *directory, bool contiguous)
{
AlphabeticSDFileList::SD = &SdFat;
AlphabeticSDFileList::contiguous = contiguous;
AlphabeticSDFileList::directory = directory;

strcpy(first, "");
strcpy(last, "");
strcpy(current, "");

char filename[DEFAULT_FILE_NAME_SIZE];

File directoryFile = SD->open(directory);

while (true) {
File file = directoryFile.openNextFile();

if (!file) {
// no more files
break;
}

file.getName(filename, DEFAULT_FILE_NAME_SIZE);

if (!file.isDirectory()) {
if (strcmp(first, "") == 0) {
strcpy(first, filename);
}
else {
if (strcmp(filename, first) < 0) {
strcpy(first, filename);
}
else {
if (strcmp(filename, last) > 0) {
strcpy(last, filename);
}
}
}
}

file.close();
}
}

char* AlphabeticSDFileList::First()
{
return first;
}

char* AlphabeticSDFileList::Last()
{
return last;
}

char* AlphabeticSDFileList::Current()
{
return current;
}

char* AlphabeticSDFileList::Previous()
{
char filename[DEFAULT_FILE_NAME_SIZE];
char previous[DEFAULT_FILE_NAME_SIZE];

strcpy(previous, "");

if (strcmp(current, "") == 0)
strcpy(current, "\x7F");

File directoryFile = SD->open(directory);

while (true) {
File file = directoryFile.openNextFile();

if (!file) {
// no more files
break;
}

file.getName(filename, DEFAULT_FILE_NAME_SIZE);

if (!file.isDirectory()) {
if (strcmp(filename, current) < 0) {
if (strcmp(previous, "") == 0) {
strcpy(previous, filename);
}
else {
if (strcmp(filename, previous) > 0) {
strcpy(previous, filename);
}
}
}
}

file.close();
}

if (contiguous && strcmp(previous, "") == 0)
strcpy(previous, last);

strcpy(current, previous);
return current;
}

char* AlphabeticSDFileList::Next()
{
char filename[DEFAULT_FILE_NAME_SIZE];
char next[DEFAULT_FILE_NAME_SIZE];

strcpy(next, "");

File directoryFile = SD->open(directory);

while (true) {
File file = directoryFile.openNextFile();

if (!file) {
// no more files
break;
}

file.getName(filename, DEFAULT_FILE_NAME_SIZE);

if (!file.isDirectory()) {
if (strcmp(filename, current) > 0) {
if (strcmp(next, "") == 0) {
strcpy(next, filename);
}
else {
if (strcmp(filename, next) < 0) {
strcpy(next, filename);
}
}
}
}

file.close();
}

if (contiguous && strcmp(next, "") == 0)
strcpy(next, first);

strcpy(current, next);
return current;
}
34 changes: 34 additions & 0 deletions AlphabeticSDFileList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
AlphabeticSDFileList.h - Library for listing SD files in a directory on alphabetic order.
Created by Terence F. Golla, April 17, 2022
Released into the public domain.
*/

#ifndef AlphabeticSDFileList_h
#define AlphabeticSDFileList_h

#include <Arduino.h>
#include <SdFat.h> // SD card & FAT filesystem library.

#define DEFAULT_FILE_NAME_SIZE 32

class AlphabeticSDFileList
{
public:
AlphabeticSDFileList();
void Begin(SdFat &SD, char *directory, bool contiguous);
char* First();
char* Last();
char* Current();
char* Previous();
char* Next();
private:
SdFat *SD;
char first[DEFAULT_FILE_NAME_SIZE];
char last[DEFAULT_FILE_NAME_SIZE];
char current[DEFAULT_FILE_NAME_SIZE];
bool contiguous;
char* directory;
};

#endif
26 changes: 16 additions & 10 deletions Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef Configuration_h
#define Configuration_h

// Add debugging (M999) command.
// Add debugging (M999) command. Note: Memory intensive.
#define DEBUG true

// Set to true if you are using an Adafruit 2.8" TFT Touch Shield for
Expand All @@ -36,6 +36,14 @@
// The display uses hardware SPI, plus #9 & #10.
#define TFT_CS 10
#define TFT_DC 9
#define TFT_ROTATION 3
#define TFT_HEIGHT 240
#define TFT_WIDTH 320
#define TFT_TEXT_SIZE 1
#define TFT_TEXT_HEIGHT 8
#define TFT_TEXT_WIDTH 6
#define TFT_TEXT_COLOR ILI9341_WHITE
#define TFT_TEXT_BACKGROUND_COLOR ILI9341_BLACK
#define FT6206_THRESSHOLD 0x80

// Splash screen display delay in milliseconds.
Expand All @@ -45,9 +53,7 @@
#define SD_CS 4


// Version of Adafruit motor shield used. One of the two lines should be commented out.

//#define ADAFRUIT_MOTOR_SHIELD_VERSION 1
// Version of Adafruit motor shield used. Set to version 1 or 2.
#define ADAFRUIT_MOTOR_SHIELD_VERSION 2

/*
Expand Down Expand Up @@ -95,7 +101,7 @@

// Default pen up/down positions.
#define DEFAULT_PEN_UP_POSITION 145
#define DEFAULT_PEN_DOWN_POSITION 115
#define DEFAULT_PEN_DOWN_POSITION 125

// The default Pen feedrate in degrees/second. Necessary should G-Code not contain feedrate.
#define DEFAULT_PEN_FEEDRATE 200.0
Expand All @@ -115,9 +121,9 @@
// MZ Mode
// 0 - M mode allows for normal pen control using M300 commands.
// 1 - Z mode allows for pen control using G0, G1, G2 & G3 Z code parameter.
// 2 - Auto mode scans the file on the SD to automatically set the active MZ mode
// to either M or Z mode. When using the serial USB port the active mode
// defaults to M mode.
// 2 - Auto mode determines the active MZ mode based on the first pen control command received.
// A M300 command will set the active MZ mode to M mode.
// A G0, G1, G2 & G3 command with a Z code parameter will set the active MZ mode to Z mode.
#define DEFAULT_MZ_MODE 0

// The M Adjusted mode allows for the M300 S code parameter to be adjusted. This
Expand All @@ -140,12 +146,12 @@
// values below the calculated value are adjusted to the pen down seting.
#define DEFAULT_Z_ADJUST 0

// If in serial USB mode the G-Code cannot be preprocessed (scanned) for maximun and minimun
// In serial USB mode the G-Code cannot be preprocessed (scanned) for maximun and minimun
// values to set the absolute or average adjustment threshold. In this case the following
// default is used for M300 commands. The value can also be set with the M308 command.
#define DEFAULT_M_ADJUST_PRESET 145

// If in serial USB mode the G-Code cannot be preprocessed (scanned) for maximun and minimun
// In serial USB mode the G-Code cannot be preprocessed (scanned) for maximun and minimun
// values to set the absolute or average adjustment threshold. In this case the following
// default is used for G0, G1, G2, & G3 Z parameters. The value can also be set with the M309 command.
#define DEFAULT_Z_ADJUST_PRESET 5
Expand Down
Loading

0 comments on commit b95cac5

Please sign in to comment.