Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

instead reading from the pointer, now read directly storage with posi…

…tion
  • Loading branch information...
commit ff4abe1b725a10b9ea72cb08b3ae6c2a6caa99c9 1 parent 3c48fdc
@sweemeng authored
View
25 libraries/storyboard/WordGenerator.cpp
@@ -51,8 +51,6 @@ int WordGenerator::get_delimiter(int pos){
p = p + 1;
}
check = this->storage.read(p);
- //Serial.println(p);
- //Serial.println(delimiter);
while(check != ':'){
if(p > this->segment_end){
p = this->begin + 1;
@@ -60,7 +58,6 @@ int WordGenerator::get_delimiter(int pos){
p++;
check = this->storage.read(p);
}
- //Serial.println(check);
return p;
}
@@ -70,34 +67,23 @@ char *WordGenerator::word_select(){
if(word_start == this->segment_end){
word_start = this->segment_begin;
}
- Serial.println(word_start);
this->begin = word_start;
int word_end = this->get_delimiter(word_start+1);
- //Serial.println(this->storage.read(word_start));
- //Serial.println(this->storage.read(word_end));
word_start = word_start + 1;
word_end = word_end;
this->end = word_end;
- Serial.println(word_end);
int word_size = word_end - word_start;
- //Serial.println(word_size);
char *s_word;
s_word = (char *)malloc(word_size * sizeof(char));
int count = 0;
for(int i = word_start;i < word_end;i++){
s_word[count] = storage.read(i);
- Serial.write(s_word[count]);
- //s_word++;
count++;
- if(count == word_size){
-
-
+ if(count == word_size){
break;
}
- //delay(500);
}
- Serial.println(sizeof(*s_word));
return s_word;
}
@@ -116,3 +102,12 @@ void WordGenerator::put_storage(int pos,int data){
char WordGenerator::get_storage(int pos){
return this->storage.read(pos);
}
+
+int WordGenerator::get_word_begin(){
+
+ return this->begin;
+}
+
+int WordGenerator::get_word_end(){
+ return this->end;
+}
View
2  libraries/storyboard/WordGenerator.h
@@ -17,6 +17,8 @@ class WordGenerator{
int get_segment_end();
void put_storage(int,int);
char get_storage(int);
+ int get_word_begin();
+ int get_word_end();
private:
int begin;
int end;
View
1  libraries/storyboard/WordStorage.cpp
@@ -35,7 +35,6 @@ byte WordStorage::read_byte(unsigned int eeaddress){
Wire.requestFrom(this->deviceaddress,1);
if (Wire.available()){
rdata = Wire.receive();
- Serial.println("reading");
}
return rdata;
View
29 storybox/storybox.pde
@@ -41,14 +41,25 @@ void loop(){
int segment = TrueRandom.random(0,7);
digitalWrite(statusLed,HIGH);
digitalWrite(buzzer,HIGH);
- generator.get_segment(0);
+ generator.get_segment(segment);
free(s_word);
*s_word = NULL;
s_word = generator.word_select();
- lcd.printIn(s_word);
-
- Serial.println(s_word);
- delay(500);
+ int s_start = generator.get_word_begin();
+ int s_end = generator.get_word_end();
+
+ int l_cursor = 0;
+
+ for(int i = s_start+1;i<s_end;i++){
+ lcd.cursorTo(1,l_cursor);
+ char letter = generator.get_storage(i);
+ lcd.printIn(&letter);
+ Serial.write(letter);
+ l_cursor++;
+ }
+ Serial.println(" ");
+
+
}else{
digitalWrite(statusLed,LOW);
@@ -60,7 +71,7 @@ void data_load(){
storage_size = 0;
int value;
value = Serial.read();
- //Serial.write(value);
+
if(value == 60){
while(value != 62){
value = Serial.read();
@@ -73,11 +84,5 @@ void data_load(){
}
}
generator.put_storage(0,0);
- if(storage_size > 0){
- Serial.println(" ");
- for(int i=0;i<storage_size;i++){
- Serial.print((char)generator.get_storage(i));
- }
- }
}
Please sign in to comment.
Something went wrong with that request. Please try again.