Skip to content

Commit

Permalink
Merge pull request #9 from tgolla/TouchscreenV2
Browse files Browse the repository at this point in the history
Touchscreen v2 Pre-release 1.9.4
  • Loading branch information
tgolla authored Nov 11, 2022
2 parents 171c0ad + a60e349 commit 172a078
Show file tree
Hide file tree
Showing 60 changed files with 1,532,377 additions and 78 deletions.
131 changes: 120 additions & 11 deletions AlphabeticSDFileList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@ Released into the public domain.

#include "AlphabeticSDFileList.h"

/// <summary>
/// Class constructor.
/// </summary>
AlphabeticSDFileList::AlphabeticSDFileList() { }

/// <summary>
/// Class initializer.
/// </summary>
/// <param name="SdFat">The SD Fat object created to read the card.</param>
/// <param name="directory">The directory on the SD to list.</param>
/// <param name="contiguous">Boolean indicating Previous and Next are
/// to loop through the directory start to end and end to start.</param>
/// <remarks>If you add files to the directory you will need to re-execute Begin.</remarks>
void AlphabeticSDFileList::Begin(SdFat &SdFat, char *directory, bool contiguous)
{
AlphabeticSDFileList::SD = &SdFat;
Expand All @@ -22,6 +33,7 @@ void AlphabeticSDFileList::Begin(SdFat &SdFat, char *directory, bool contiguous)

File directoryFile = SD->open(directory);

// Loop through entire directory (file list). Note the file list is not ordered.
while (true) {
File file = directoryFile.openNextFile();

Expand All @@ -32,15 +44,20 @@ void AlphabeticSDFileList::Begin(SdFat &SdFat, char *directory, bool contiguous)

file.getName(filename, DEFAULT_FILE_NAME_SIZE);

// If we are looking at a filename (not a directory)
if (!file.isDirectory()) {
// If the first filename is empty, fill first and last.
if (stricmp(first, "") == 0) {
strcpy(first, filename);
strcpy(last, filename);
}
else {
// If the filename is less than the first filename, place it in first.
if (stricmp(filename, first) < 0) {
strcpy(first, filename);
}
else {
// If the filename is greater than the last filename, place it in last.
if (stricmp(filename, last) > 0) {
strcpy(last, filename);
}
Expand All @@ -52,33 +69,57 @@ void AlphabeticSDFileList::Begin(SdFat &SdFat, char *directory, bool contiguous)
}
}

int AlphabeticSDFileList::stricmp(const char *s1, const char *s2)
{
while (toupper(*s1) == toupper(*s2))
{
if (*s1 == 0)
return 0;
s1++;
s2++;
}
return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2));
}
/// <summary>
/// String compare without case sensitivity.
/// </summary>
/// <param name="s1">The first string (string1).</param>
/// <param name="s2">The second string (string2).</param>
/// <returns>Less than 0 if string1 is less than string2. 0 if string1 equivalent to string2. Greater than 0 if string1 is greater than string2.</returns>
int AlphabeticSDFileList::stricmp(const char *s1, const char *s2)
{
while (tolower((unsigned char) *s1) == tolower((unsigned char) *s2)) {
if (*s1 == '\0')
return 0;
s1++; s2++;
}

return (int) tolower((unsigned char) *s1) - (int) tolower((unsigned char) *s2);
}

/// <summary>
/// The first file in the directory.
/// </summary>
char* AlphabeticSDFileList::First()
{
return first;
}

/// <summary>
/// The last file in the directory.
/// </summary>
char* AlphabeticSDFileList::Last()
{
return last;
}

/// <summary>
/// The current file as you progress through the list.
/// </summary>
char* AlphabeticSDFileList::Current()
{
return current;
}

/// <summary>
/// Moves to the previous file in the list.
/// </summary>
/// <returns>The previous filename.</returns>
/// <remarks>
/// If contiguous was set to true and the current file is the fisrt file in the list
/// Previous will return the last file in the list.
/// If contiguous was set to false and the current file is the fisrt file in the list
/// Previous will return a blank filename.
/// </remarks>
char* AlphabeticSDFileList::Previous()
{
char filename[DEFAULT_FILE_NAME_SIZE];
Expand All @@ -91,6 +132,7 @@ char* AlphabeticSDFileList::Previous()

File directoryFile = SD->open(directory);

// Loop through entire directory (file list). Note the file list is not ordered.
while (true) {
File file = directoryFile.openNextFile();

Expand All @@ -101,12 +143,16 @@ char* AlphabeticSDFileList::Previous()

file.getName(filename, DEFAULT_FILE_NAME_SIZE);

// If we are looking at a filename (not a directory).
if (!file.isDirectory()) {
// If the filename is less than the current filename, it might be the previous file.
if (stricmp(filename, current) < 0) {
// If the previous filename is empty, fill it with the filename.
if (stricmp(previous, "") == 0) {
strcpy(previous, filename);
}
else {
// If the filename is greater than the previous filename, make it the previous filename.
if (stricmp(filename, previous) > 0) {
strcpy(previous, filename);
}
Expand All @@ -124,6 +170,16 @@ char* AlphabeticSDFileList::Previous()
return current;
}

/// <summary>
/// Moves to the next file in the list.
/// </summary>
/// <returns>The next filename.</returns>
/// <remarks>
/// If contiguous was set to true and the current file is the last file in the list
/// Next will return the first file in the list.
/// If contiguous was set to false and the current file is the last file in the list
/// Previous will return a blank filename.
/// </remarks>
char* AlphabeticSDFileList::Next()
{
char filename[DEFAULT_FILE_NAME_SIZE];
Expand All @@ -133,6 +189,7 @@ char* AlphabeticSDFileList::Next()

File directoryFile = SD->open(directory);

// Loop through entire directory (file list). Note the file list is not ordered.
while (true) {
File file = directoryFile.openNextFile();

Expand All @@ -143,12 +200,16 @@ char* AlphabeticSDFileList::Next()

file.getName(filename, DEFAULT_FILE_NAME_SIZE);

// If we are looking at a filename (not a directory).
if (!file.isDirectory()) {
// If the filename is greater than the current filename, it might be the next file.
if (stricmp(filename, current) > 0) {
// If the next filename is empty, fill it with the filename.
if (stricmp(next, "") == 0) {
strcpy(next, filename);
}
else {
// If the filename is less than the next filename, make it the next filename.
if (stricmp(filename, next) < 0) {
strcpy(next, filename);
}
Expand All @@ -165,3 +226,51 @@ char* AlphabeticSDFileList::Next()
strcpy(current, next);
return current;
}

/// <summary>
/// Finds the closest match to the provided filename.
/// </summary>
/// <param name="filename">The filename to match.</param>
/// <returns>The closest match to the provided filename.</returns>
char* AlphabeticSDFileList::Find(char *findFilename)
{
char filename[DEFAULT_FILE_NAME_SIZE];
char next[DEFAULT_FILE_NAME_SIZE];

strcpy(current, last);

File directoryFile = SD->open(directory);

// Loop through entire directory (file list). Note the file list is not ordered.
while (true) {
File file = directoryFile.openNextFile();

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

file.getName(filename, DEFAULT_FILE_NAME_SIZE);

// If we are looking at a filename (not a directory).
if (!file.isDirectory()) {
// If the current filename is empty, fill it.
if (stricmp(current, "") == 0) {
strcpy(current, filename);
}
else {
// If the filename is greater than or equal the find filename.
if (stricmp(filename, findFilename) >= 0) {
// If the filename is less than the current filename, fill the current filename.
if (stricmp(filename, current) < 0) {
strcpy(current, filename);
}
}
}
}

file.close();
}

return current;
}
1 change: 1 addition & 0 deletions AlphabeticSDFileList.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AlphabeticSDFileList
char* Current();
char* Previous();
char* Next();
char* Find(char *findFilename);
private:
SdFat *SD;
stricmp(const char *s1, const char *s2);
Expand Down
71 changes: 71 additions & 0 deletions Documentation/Assembly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# **SphereBot** - An EggBot Clone <br/>*Assembly Overview*

## Overview

One of the issues I have with Thingiverse.com is that a large amount of user uploads are half-finished projects in the mind of an engineer. In particular, they provide wonderful ideas in the form of STL files, but they don’t bother to provide the original CAD files, a BOM (Bill of Materials) list, assembly instructions and any other relevant information. It is my hope that this and the other documents in this project provide a complete understanding for even a novice to build a SphereBot. Please use the GitHub issues to provide any feedback.

## 3D Prints

The orginal project build uses the following 3D printed parts from the Thingiverse project Improved Printable Eggbot by nglasson published March 5, 2014 (http://www.thingiverse.com/thing:263668).

Quantity | Part | File
--- | --- | ---
1 | Back Plate | back_plate.stl
1 | Brace - Driver Side | brace_-_drive_end.stl
1 | Brace - Idler Side | brace_-_idler_end.stl
1 | Drive Cup | drive_cup.stl
3 | End Plates | end_plate.stl
4 | Idler Bearing Plates | idler_bearing_plate.stl
2 | Idler Cup | idler_cup.stl
1 | Pen Arm Pivot | pen_arm_pivot.stl
1 | Pen Arm Shaft Coupler | pen_arm_shaft_coupler.stl
1 | Pen Arm Top | pen_arm_top.stl
1 | Spring | spring.stl

I am currently working on a second bulid using the Thingiverse project SphereBot Redrawn by jsc published May 23, 2015 (https://www.thingiverse.com/thing:844167). This addition is a work in progress and will be documented as time allows.

Quantity | Part | File
--- | --- | ---
1 | Back Plate | back_plate.gcode
1 | Pen Arm Shaft Coupler Cradlepoint.gcode
1 | Drive Cup | drive_cup.gcode
1 | End Plate | end_plate.stl
2 | Idler Cup | idler_cup.gcode
2 | Idler End Plate | idler_end_plate_v2.stl
1 | Brace - Driver Side | left_brace.gcode
1 | Pen Arm Pivot | pen_arm_pivot.gcode
1 | Pen Arm Top | pen_arm_top.gcode
1 | Brace - Idler Side | right_brace_v2.gcode
1 | Spring | spring.gcode

You will find the project benefits greatly from the Thingiverse project Leg Truss for Improved Printable EggBot by Daniel_Isdell published May 24, 2014 (http://www.thingiverse.com/thing:341204)

Quantity | Part | File
--- | --- | ---
2 | Leg Trusses | Leg-Truss2.stl

If you are building the original SphereBot configuration you will find the Thingiverse project From Arduino Uno mount for Glasswalkers Revised Fully Printable Eggbot by MarkBenson published June 4, 2012 (http://www.thingiverse.com/thing:24256) useful to mount the arduino.

Quantity | Part | File
--- | --- | ---
1 | Arduino Mounting Plate | mountingplateandsupportsv0.2.5_fixed.stl

For the version 2 touchscreen SphereBot configuration you will want to print 2 of the LCD mounts. The STL file for a single mount an washer spacers can be found in the STL folder.

Quantity | Part | File
--- | --- | ---
2 | Arduino LCD Mount | Arduino_LCD_Mount.stl

## Bill of Materials
*To be completed in the a future release.*

Reference the Electronics Overview documentation for a bill of meterials for all of the projects electronic parts.

## Sourcing
*To be completed in the a future release.*

## Document History

Date | Author | Change Summary
--- | --- | ---
9/3/2022 | Terence Golla | Document Created
4 changes: 2 additions & 2 deletions Documentation/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ The ```FORWARD_REWIND_COUNT``` directive set the number of file jumped forward o
The ```SPLASH_SCREEN_DELAY``` directive sets the SD card chip select pin. The default setting is 4.

## OUTPUT_GCODE_TO
The ```OUTPUT_GCODE_TO``` directive defines where processed g-code is output. This setting determines if g-code is to be output to only the display, only the serial port, both or neither. This directive is only relavant for with the touchscreen/SD configuration running in SD mode. In classic mode processed g-code is always sent to the serial port. The option is useful for increasing print speed and debugging. When set to the default, display only it provides a visual g-code being processed. However, display calls have a high processor utilization which reduces the print speed. When set to serial only or both g-code is output to the serial port which can be monitored. This can be useful when debugging, but also results in a high processor utilization. When set to neither g-code is not displayed or sent to the serial port resulting in increased printing speed. The following numerical settings should be used (0-Neither, 1-Serial Only, 2-Display Only, 3-Both). The default setting is Display Only (2).
The ```OUTPUT_GCODE_TO``` directive defines where processed g-code is output. This setting determines if g-code is to be output to only the display, only the serial port, both or neither. This directive is only relavant for with the touchscreen/SD configuration running in SD mode. In classic mode processed g-code is always sent to the serial port. The option is useful for increasing print speed and debugging. When set to the default, display only it provides a visual g-code being processed. However, display calls have a high processor utilization which can increase the print time 5 fold. When set to serial only or both g-code is output to the serial port which can be monitored. This can be useful when debugging. Serial only does not incease processor utilization. When set to neither g-code is not displayed or sent to the serial port resulting in increased printing speed. The following numerical settings should be used (0-Neither, 1-Serial Only, 2-Display Only, 3-Both). The default setting is Display Only (2).

## PERCENTAGE_TIME_CALCULATION_ENABLED
The ```PERCENTAGE_TIME_CALCULATION_ENABLED``` directive sets the default setting of the percentage completed and time remaining calculation. This setting determines if the percentage completed and time remaining calculation is executed and displayed on the screen when printing. The option to turn off the calculation is available to increase print speed and reduce print time. This directive is only relavant for with the touchscreen/SD configuration. The default setting is true.
The ```PERCENTAGE_TIME_CALCULATION_ENABLED``` directive sets the default setting of the percentage completed and time remaining calculation. This setting determines if the percentage completed and time remaining calculation is executed and displayed on the screen when printing. The option to turn off the calculation is available to increase print speed and reduce print time. The calculation will increase print time by 1/3. This directive is only relavant for with the touchscreen/SD configuration. The default setting is true.

## PIEZO_PIN
The ```PIEZO_PIN``` directive sets the piezo buzzer pin. To deactivate the buzzer set the value to -1. The default setting is 3.
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Electronics.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The first notable design change in this SphereBot project is the replacement of

The second major design change is the addition of a touchscreen, SD card slot and buzzer. This allows the SphereBot to operate independently of a PC with g-code stored on the SD card along with audible alerts and the simplicity that even a child could operate.

## Parts
## Bill of Materials
### v1 Orinal Configuration
The following electronic parts are required for the original SphereBot configuration. Version 2.x of the software still supports the orginal configuration, but at present only supports the Adafruit motor control shield.

Expand Down
4 changes: 2 additions & 2 deletions Documentation/G-Code.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ The M311 command allows you to override the pen movement feed rates set in your
### M312
The M312 command sets the pen up federate multiplier. This command allows the SphereBot to move off the object at a faster rate. One means the pen will go up at the same speed (degrees/second) as it goes down. Each increase by one will logarithmically double the pen up speed.
### M990
Sets the g-code output device print device. When set to Neither (P0) output of the g-code is disable, except in classic mode which always outputs g-code to the serial port. When set to Serial Only (P1) g-code is output to just the serial port. This can be useful when debugging, but results in a high processor utilization. When set to Display Only (P2) g-code is output to just the display. This also results in a high processor utilization. When set to Both (P3) g-code is output to both the serial port and the display. This directive is only relavant for with the touchscreen/SD configuration running in SD mode.
Sets the g-code output device print device. When set to Neither (P0) output of the g-code is disable, except in classic mode which always outputs g-code to the serial port. When set to Serial Only (P1) g-code is output to just the serial port. This can be useful when debugging with a nominal increase in processor utilization. When set to Display Only (P2) g-code is output to just the display. This will results in a high processor utilization such that printing time increases 5 fold. When set to Both (P3) g-code is output to both the serial port and the display. This setting also increases printing time 5 fold. This directive is only relavant for with the touchscreen/SD configuration running in SD mode.

### M991
Disable/Enable percentage completed and time remaining calculation. The ability to disable the percentage completed and time remaining calculation is provided to increase speed by reducing processor calculations during printing. When set to disabled (P0) the calculation is disabled. When set to enabled (P1) the calculation is enabled and displayed. This command is only relavant for with the touchscreen/SD configuration.
Disable/Enable percentage completed and time remaining calculation. The ability to disable the percentage completed and time remaining calculation is provided to increase speed by reducing processor calculations during printing. When set to disabled (P0) the calculation is disabled. When set to enabled (P1) the calculation is enabled and displayed. The calculation will increase print time by 1/3. This command is only relavant for with the touchscreen/SD configuration.

### Using M3xx commands.
Using a file to preset the M301 through M312 values and saving the configuration with the M500 command provides a great deal of versatility.
Expand Down
Loading

0 comments on commit 172a078

Please sign in to comment.