Skip to content

Commit

Permalink
writeStr now takes String class
Browse files Browse the repository at this point in the history
genie.writeStr can now accept String type variables
  • Loading branch information
4D Systems committed Sep 16, 2015
1 parent b810ee9 commit 6632d8e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
7 changes: 6 additions & 1 deletion genieArduino/Examples/WriteStr_Demo/WriteStr_Demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void loop()
long y = 171;
double z = 175.3456;
int digits = 3;
String Str = "This is string class";
genie.WriteStr(0, "TEST");
delay(1000);
genie.WriteStr(0, z, digits); //3 decimal places
Expand All @@ -57,8 +58,10 @@ void loop()
delay(1000);
genie.WriteStr(0, 123.45678); // 2 decimal places by default if no value is given to decimal place.
delay(1000);
genie.WriteStr(0, F("This string will be stored in flash memory")); // For AVR Arduinos only - Needs to be commented out for Due, Chipkit, Teensy etc.
genie.WriteStr(0, F("This string will be \n stored in flash memory")); // For AVR Arduinos only - Needs to be commented out for Due, Chipkit, Teensy etc.
delay(1000);
genie.WriteStr(0, " "); // Clear
delay(10);
genie.WriteStr(0, x);
delay(1000);
genie.WriteStr(0, y);
Expand All @@ -71,6 +74,8 @@ void loop()
delay(1000);
genie.WriteStr(0, 10,8); //base 8
delay(1000);
genie.WriteStr(0, Str); //prints String Class
delay(1000);
}


12 changes: 11 additions & 1 deletion genieArduino/genieArduino.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/////////////////////// GenieArduino 03/09/2015 ///////////////////////
/////////////////////// GenieArduino 16/09/2015 ///////////////////////
//
// Library to utilise the 4D Systems Genie interface to displays
// that have been created using the Visi-Genie creator platform.
Expand Down Expand Up @@ -744,6 +744,16 @@ uint16_t Genie::WriteStr(uint16_t index, const __FlashStringHelper *ifsh){
}
#endif

uint16_t Genie::WriteStr(uint16_t index, const String &s){
//s.c_str(), s.length()
int len = s.length();
char arr[len + 1];
s.toCharArray(arr,len + 1);
WriteStr(index, arr);
return 0;
}


uint16_t Genie::WriteStr (uint16_t index, long n) {
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
Expand Down
5 changes: 3 additions & 2 deletions genieArduino/genieArduino.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/////////////////////// GenieArduino 03/09/2015 ///////////////////////
/////////////////////// GenieArduino 16/09/2015 ///////////////////////
//
// Library to utilize the 4D Systems Genie interface to displays
// that have been created using the Visi-Genie creator platform.
Expand Down Expand Up @@ -52,7 +52,7 @@

#undef GENIE_DEBUG

#define GENIE_VERSION "GenieArduino 03-09-2015"
#define GENIE_VERSION "GenieArduino 16-09-2015"

// Genie commands & replys:

Expand Down Expand Up @@ -181,6 +181,7 @@ class Genie {
uint16_t WriteStr (uint16_t index, long n, int base) ;
uint16_t WriteStr (uint16_t index, int n) ;
uint16_t WriteStr (uint16_t index, int n, int base) ;
uint16_t WriteStr (uint16_t index, const String &s);
#ifdef AVR
uint16_t WriteStr (uint16_t index, const __FlashStringHelper *ifsh);
#endif
Expand Down
2 changes: 1 addition & 1 deletion genieArduino/library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=genieArduino
version=201500903
version=201500916
author=4D Systems Pty Ltd
maintainer=4D Systems Pty Ltd <engineering@4dsystems.com.au>
sentence=4D Systems ViSi-Genie library for Arduino
Expand Down

0 comments on commit 6632d8e

Please sign in to comment.