Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions TeensyELS2.31/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Teensy Electronic leadscrew
This is an implementation of an electronic leadscrew using a Teensy microcrontroller.

# Architecture
We use [https://platformio.org/](platformio) as the infrastructure to build this project.

# Installation
You will currently need to setup platformio to build this, it can also handle installation to your teensy as well.
NOTE: you will have to modify some of the configuration to get this set up for your particular lathe, instructions coming soon.
39 changes: 39 additions & 0 deletions TeensyELS2.31/include/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

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
46 changes: 46 additions & 0 deletions TeensyELS2.31/lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.

The source code of each library should be placed in an own separate directory
("lib/your_library_name/[here are source files]").

For example, see a structure of the following two libraries `Foo` and `Bar`:

|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c

and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>

int main (void)
{
...
}

```

PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.

More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
19 changes: 19 additions & 0 deletions TeensyELS2.31/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:teensy41]
platform = teensy
board = teensy41
framework = arduino

lib_deps =
jsware/AbleButtons@^0.4.0
adafruit/Adafruit GFX Library@^1.11.9
adafruit/Adafruit SSD1306@^2.5.10
19 changes: 19 additions & 0 deletions TeensyELS2.31/src/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This file contains all hardware configs for your system

#pragma once

/**
* Display
*
* This setting allows you to select what type of display you want to use.
* The selection will hopefully grow as time goes on!
*
* Options:
* SSD1306_128_64: 128x64 oled
*/
#define ELS_DISPLAY SSD1306_128_64

#if ELS_DISPLAY == SSD1306_128_64
// define this if you have a dedicated pin for the oled reset
#define PIN_DISPLAY_RESET -1
#endif
154 changes: 154 additions & 0 deletions TeensyELS2.31/src/display.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#include "display.h"

// Images
#include "feedSymbol.h"
#include "lockedSymbol.h"
#include "pauseSymbol.h"
#include "runSymbol.h"
#include "threadSymbol.h"
#include "unlockedSymbol.h"

void Display::init() {
#ifdef ELS_DISPLAY == SSD1306_128_64
if (!this->m_ssd1306.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
m_ssd1306.clearDisplay();
#endif
}

void Display::update(boolean driveMode, float pitch, boolean lock,
boolean enabled, boolean jogging, boolean syncState, boolean startPointSet) {
#if ELS_DISPLAY == SSD1306_128_64
m_ssd1306.clearDisplay();
#endif

this->drawMode(driveMode);
this->drawPitch(pitch);
this->drawLocked(lock);
this->drawEnabled(enabled);
this->drawSyncState(syncState);
this->drawThreadStartPointSet(startPointSet);
this->drawJogging(jogging);


#if ELS_DISPLAY == SSD1306_128_64
m_ssd1306.display();
#endif
}

void Display::drawMode(boolean driveMode) {
#if ELS_DISPLAY == SSD1306_128_64
if (driveMode == true) {

m_ssd1306.drawBitmap(57, 32, threadSymbol, 64, 32, WHITE);
} else {
m_ssd1306.drawBitmap(57, 32, feedSymbol, 64, 32, WHITE);
}
#endif
}

void Display::drawPitch(float pitch) {
#if ELS_DISPLAY == SSD1306_128_64
m_ssd1306.setCursor(55, 6);
m_ssd1306.setTextSize(3);
m_ssd1306.setTextColor(WHITE);
m_ssd1306.print(pitch);
#endif
}

void Display::drawEnabled(boolean enabled) {
#if ELS_DISPLAY == SSD1306_128_64
m_ssd1306.fillRoundRect(26, 40, 20, 20, 2, WHITE);

if (enabled == true) {
m_ssd1306.drawBitmap(28, 42, runSymbol, 16, 16, BLACK);
} else {
m_ssd1306.drawBitmap(28, 42, pauseSymbol, 16, 16, BLACK);
}
#endif
}

void Display::drawLocked(boolean locked) {
#if ELS_DISPLAY == SSD1306_128_64
m_ssd1306.fillRoundRect(2, 40, 20, 20, 2, WHITE);

if (locked == true) {
m_ssd1306.drawBitmap(4, 42, lockedSymbol, 16, 16, BLACK);
} else {
m_ssd1306.drawBitmap(4, 42, unlockedSymbol, 16, 16, BLACK);
}
#endif
}

void Display::drawJogging(boolean jogging) {
#if ELS_DISPLAY == SSD1306_128_64


if (jogging == true) {
m_ssd1306.fillRoundRect(30, 14, 68, 36, 12, WHITE);
m_ssd1306.fillRoundRect(32, 16, 64, 32, 10, BLACK);

m_ssd1306.setCursor(37, 22);
m_ssd1306.setTextSize(3);
m_ssd1306.setTextColor(WHITE);
m_ssd1306.print("JOG");
}


#endif
}

void Display::drawSyncState(boolean syncState) {
#if ELS_DISPLAY == SSD1306_128_64


if (syncState == true) {
m_ssd1306.setCursor(2, 2);
m_ssd1306.setTextSize(2);
m_ssd1306.setTextColor(WHITE);
m_ssd1306.print("SYNC");
}

else
{
m_ssd1306.setCursor(2, 2);
m_ssd1306.setTextSize(2);
m_ssd1306.setTextColor(WHITE);
m_ssd1306.print("SYNC");
m_ssd1306.fillRoundRect(0, 8, 50, 2, 1, WHITE);
}

#endif
}

void Display::drawThreadStartPointSet(boolean startPointSet) {
#if ELS_DISPLAY == SSD1306_128_64


if (startPointSet == true) {
m_ssd1306.setCursor(2, 21);
m_ssd1306.setTextSize(2);
m_ssd1306.setTextColor(WHITE);
m_ssd1306.print("STRT");
}

else
{
m_ssd1306.setCursor(2, 21);
m_ssd1306.setTextSize(2);
m_ssd1306.setTextColor(WHITE);
m_ssd1306.print("STRT");
m_ssd1306.fillRoundRect(0, 27, 50, 2, 1, WHITE);

}
#endif

}






47 changes: 47 additions & 0 deletions TeensyELS2.31/src/display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

#include "config.h"

#define SSD1306_128_64 0

#if ELS_DISPLAY == SSD1306_128_64

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
// some displays can have different addresses, this is what we attempt to init
#define SCREEN_ADDRESS 0x3C

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#else

#error "Please choose a valid display. Refer to config.h for options"

#endif

class Display {
public:
#if ELS_DISPLAY == SSD1306_128_64
Adafruit_SSD1306 m_ssd1306;
#endif
Display() {
#if ELS_DISPLAY == SSD1306_128_64
this->m_ssd1306 =
Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, PIN_DISPLAY_RESET);
#endif
}

void init();
void update(boolean driveMode, float pitch, boolean lock, boolean enabled, boolean jogMode, boolean syncState, boolean startPointSet);

protected:
void drawMode(boolean driveMode);
void drawPitch(float rate);
void drawEnabled(boolean enabled);
void drawLocked(boolean locked);
void drawJogging(boolean jogging);
void drawSyncState(boolean syncState);
void drawThreadStartPointSet(boolean startPointSet);


};
23 changes: 23 additions & 0 deletions TeensyELS2.31/src/feedSymbol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// File generated by LCD Assistant
// http://en.radzio.dxp.pl/bitmap_converter/
//------------------------------------------------------------------------------
static const uint8_t PROGMEM feedSymbol [] = {

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFB, 0xE0, 0x06, 0x00,
0x00, 0x00, 0x00, 0x01, 0xF1, 0xF0, 0x07, 0x80, 0x00, 0x00, 0x00, 0x03, 0xE0, 0xF8, 0x07, 0xE0,
0x1F, 0xF0, 0x00, 0x07, 0xC0, 0x7F, 0xFF, 0xF8, 0x3F, 0xF8, 0x00, 0x0F, 0x80, 0x3F, 0xFF, 0xFC,
0x3F, 0xFC, 0x00, 0x1F, 0x00, 0x1F, 0xFF, 0xFC, 0x1F, 0xFE, 0x00, 0x3E, 0x00, 0x0F, 0xFF, 0xF8,
0x00, 0x1F, 0x00, 0x7C, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x0F, 0x80, 0xF8, 0x00, 0x00, 0x07, 0x80,
0x00, 0x07, 0xC1, 0xF0, 0x00, 0x00, 0x06, 0x00, 0x00, 0x03, 0xE3, 0xE0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0xF7, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
10 changes: 10 additions & 0 deletions TeensyELS2.31/src/lockedSymbol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//------------------------------------------------------------------------------
// File generated by LCD Assistant
// http://en.radzio.dxp.pl/bitmap_converter/
//------------------------------------------------------------------------------

static const uint8_t PROGMEM lockedSymbol [] = {

0x03, 0xC0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3C, 0x3C, 0x38, 0x1C, 0x78, 0x1E, 0x7F, 0xFE, 0x7F, 0xFE,
0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE
};
Loading