DGxInfinitY
New member
Need help with code for a project with Extended Database Library(Project Shade Sort)
This is for the Teensy 3.2 (but this error can probably be replicated on other devices)
I have a project I am working on, I have all the hardware done and made I just need some help with the code, I have a custom keyboard(uses standard ps/2 output to teensy) and an Adafruit display that I can use to display the information I have in the database, what I need help with is the main code, I am not looking for a handout but code suggestions and help to make the libraries communicate would be so helpful.
Here is the hardware design: https://circuits.io/circuits/5413758-project-shade-sort-rev1-7-mainboard for reference.
I am planning the use the Extended Database Library:https://playground.arduino.cc/Code/ExtendedDatabaseLibrary
and the Adafruit GFX Library + the Adafruit HX8357 Display Library for the Display: https://www.adafruit.com/product/2050
And the PS/2 Library for the Teensy3.2: https://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
Here is the code so far:
My main problem so far is that I get this error while compiling on a Linux Machine:
I compiled using the Arduino compiler(as its the only one I know about for this project) using these commands(in terminal):
and
I want to be able to make a new entry by invoking the createRecord(); function like so:
createRecord("A1", "12", "First");
with the "A1" coming from a keypress in response to a dialog on the display(not really the problem), "12" from a keypress in response to a dialog on the display(not really the problem), and "First" coming from the user input.
Ultimately the final argument in the code will look like:
createRecord(sh, si, pn);
with sh, si, pn all being strings to be added to the database entries(variables that are recieved as keyboard presses and converted to the approprate variable IE: 1 from the PS/2 keyboard would be converted to A1 and sent to the sh variable). I need the database to make an entry like: (click to zoom)
This is exatctly like a .csv but on teensy/arduino, this can also be seen on the
bit on line 33.
Any help would be awesome! Thanks again to anyone willing to take a look.
If you want to make changes to the code directly and want to help the project please consider using Github: https://github.com/DGxInfinitY/ShadeSort-BDL
This is for the Teensy 3.2 (but this error can probably be replicated on other devices)
I have a project I am working on, I have all the hardware done and made I just need some help with the code, I have a custom keyboard(uses standard ps/2 output to teensy) and an Adafruit display that I can use to display the information I have in the database, what I need help with is the main code, I am not looking for a handout but code suggestions and help to make the libraries communicate would be so helpful.
Here is the hardware design: https://circuits.io/circuits/5413758-project-shade-sort-rev1-7-mainboard for reference.
I am planning the use the Extended Database Library:https://playground.arduino.cc/Code/ExtendedDatabaseLibrary
and the Adafruit GFX Library + the Adafruit HX8357 Display Library for the Display: https://www.adafruit.com/product/2050
And the PS/2 Library for the Teensy3.2: https://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
Here is the code so far:
Code:
/* Project Shade Sort V0.1 Pre-Alpha Code
// Developers:
// Donovan Goodwin (DGxInfinitY): ddg2goodwin@gmail.com
//
// v0.1:
// Basic Code, as of this release the code is not fully functional.
//
//
//
*/
#include <avr/pgmspace.h>
#include <Arduino.h>
#include <EDB.h>
#include <EEPROM.h>
#include <PS2Keyboard.h>
#define TABLE_SIZE 512
//Data and Clock Pins for the Keyboard
const int DataPin = 15;
const int IRQpin = 14;
//PS2Keyboard into keyboard
PS2Keyboard keyboard;
//record info, this is how the record gets recorded.
struct newPuck {
int shade;
int size;
int puckname;
}
newPuck;
//defines the way to read and record the record in eeprom.
void writer(unsigned long address, byte data) {
EEPROM.write(address, data);
}
byte reader(unsigned long address) {
return EEPROM.read(address);
}
//Create an EDB object with the appropriate write and read handlers
EDB db(&writer, &reader);
void printError(EDB_Status err) {
Serial.print("ERROR: ");
switch (err)
{
case EDB_OUT_OF_RANGE:
Serial.println("Recno out of range");
break;
case EDB_TABLE_FULL:
Serial.println("Table full");
break;
case EDB_OK:
default:
Serial.println("OK");
break;
}
}
//Used to create the new records with the variable, shade, size, and puckname.
void createRecord(const char * shade, const char * size, const char * puckname) {
Serial.printf("Creating Record...");
newPuck.shade = shade;
newPuck.size = size;
newPuck.puckname = puckname;
EDB_Status result = db.appendRec(EDB_REC newPuck);
if (result != EDB_OK) printError(result);
Serial.println("DONE");
}
//Delete one record by specifiing the recordnumber "recno"
void deleteOneRecord(int recno) {
Serial.print("Deleting Record No: ");
Serial.println(recno);
db.deleteRec(recno);
}
//Counts all the records that are in the table.
void countRecords() {
Serial.print("Record Count: ");
Serial.println(db.count());
}
//Startup Stuff Begins
void setup() {
Serial.begin(9600);
Serial.print("Starting system...");
// create table at with starting address 0
db.create(0, TABLE_SIZE, (unsigned int)sizeof(newPuck));
Serial.println("DONE");
//Counts the total ammt. of Records
Serial.print("Count Records...");
countRecords();
Serial.println("DONE");
//Keyboard Load
keyboard.begin(DataPin, IRQpin);
Serial.print("Keyboard Ready...");
Serial.println("DONE");
//Create our First Record with the Shade "A1" Size of "!2mm" and the Name of "First"
createRecord("A1", "12", "First");
}
void loop() {
//Keyboard input search(Right Now it's nonfunctional within the code.)
if (keyboard.available()) {
// read the next key
char c = keyboard.read();
// check for some of the special keys
if (c == PS2_ENTER) {
Serial.println();
} else if (c == PS2_TAB) {
Serial.print("[Tab]");
} else if (c == PS2_ESC) {
Serial.print("[ESC]");
} else if (c == PS2_PAGEDOWN) {
Serial.print("[PgDn]");
} else if (c == PS2_PAGEUP) {
Serial.print("[PgUp]");
} else if (c == PS2_LEFTARROW) {
Serial.print("[Left]");
} else if (c == PS2_RIGHTARROW) {
Serial.print("[Right]");
} else if (c == PS2_UPARROW) {
Serial.print("[Up]");
} else if (c == PS2_DOWNARROW) {
Serial.print("[Down]");
} else if (c == PS2_DELETE) {
Serial.print("[Del]");
} else {
// otherwise, just print all normal characters
Serial.print(c);
}
}
}
My main problem so far is that I get this error while compiling on a Linux Machine:
Code:
/home/donovan/Github/ShadeSort-BDL/ss-01/ss-01.ino: In function 'void createRecord(const char*, const char*, const char*)':
/home/donovan/Github/ShadeSort-BDL/ss-01/ss-01.ino:66:17: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
newPuck.shade = shade;
^
/home/donovan/Github/ShadeSort-BDL/ss-01/ss-01.ino:67:16: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
newPuck.size = size;
^
/home/donovan/Github/ShadeSort-BDL/ss-01/ss-01.ino:68:20: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
newPuck.puckname = puckname;
^
I compiled using the Arduino compiler(as its the only one I know about for this project) using these commands(in terminal):
Code:
/home/donovan/arduino-1.8.4/arduino-builder -dump-prefs -logger=machine -hardware /home/donovan/arduino-1.8.4/hardware -tools /home/donovan/arduino-1.8.4/tools-builder -tools /home/donovan/arduino-1.8.4/hardware/tools/avr -built-in-libraries /home/donovan/arduino-1.8.4/libraries -libraries /home/donovan/Arduino/libraries -fqbn=teensy:avr:teensy31:usb=serial,speed=120,opt=o2std,keys=en-us -ide-version=10804 -build-path BUILD/Arduinobuild/ -warnings=none -build-cache BUILD/Arduinocache/ -verbose /home/donovan/Github/ShadeSort-BDL/ss-01/ss-01.ino
Code:
/home/donovan/arduino-1.8.4/arduino-builder -compile -logger=machine -hardware /home/donovan/arduino-1.8.4/hardware -tools /home/donovan/arduino-1.8.4/tools-builder -tools /home/donovan/arduino-1.8.4/hardware/tools/avr -built-in-libraries /home/donovan/arduino-1.8.4/libraries -libraries /home/donovan/Arduino/libraries -fqbn=teensy:avr:teensy31:usb=serial,speed=120,opt=o2std,keys=en-us -ide-version=10804 -build-path BUILD/Arduinobuild/ -warnings=none -build-cache BUILD/Arduinocache/ -verbose /home/donovan/Github/ShadeSort-BDL/ss-01/ss-01.ino
I want to be able to make a new entry by invoking the createRecord(); function like so:
createRecord("A1", "12", "First");
with the "A1" coming from a keypress in response to a dialog on the display(not really the problem), "12" from a keypress in response to a dialog on the display(not really the problem), and "First" coming from the user input.
Ultimately the final argument in the code will look like:
createRecord(sh, si, pn);
with sh, si, pn all being strings to be added to the database entries(variables that are recieved as keyboard presses and converted to the approprate variable IE: 1 from the PS/2 keyboard would be converted to A1 and sent to the sh variable). I need the database to make an entry like: (click to zoom)
This is exatctly like a .csv but on teensy/arduino, this can also be seen on the
Code:
struct newPuck {
int shade;
int size;
int puckname;
}
Any help would be awesome! Thanks again to anyone willing to take a look.
If you want to make changes to the code directly and want to help the project please consider using Github: https://github.com/DGxInfinitY/ShadeSort-BDL
Last edited: