Get maximum value of date when reading data from HDFS through R - r

I have saved some data from a dataframe in a file in HDFS. I can fetch maximum date from that variable like this:
print(max(gaDataEcommerce4$date))
This is what my function looks like:
writeToHDFS <- function(fileName){
print(fileName)
hdfs.init()
modelfile <- hdfs.file(fileName, "w")
hdfs.write(get(fileName), modelfile)
hdfs.close(modelfile)
}
Now, How do I to read this data from the file it was stored in?
I have tried this:
getLastDataImportDate = function(){
hdfs.init()
f = hdfs.file("/user/rstudio/gaDataEcommerce4","r")
print(f)
m = hdfs.read(f)
print(m)
c = rawToChar(m) #Throws ERROR HERE
}
However, at function rawToChar(m) , I get an error that looks something like this.
Error in rawToChar(m) :
embedded nul in string: 'X\n\0\0\0\002\0\003\002\003\0\002\003\
Why do I get this error and how do I fix this? It looks like it's because of null in here but using rm.na=TRUE does not seem to help.
Also, I have tried using
c = data.frame(m)
but it returns NULL for c$date.
Function unserialize did not help either.
Edit: When I dput the f fetched , it renders this:
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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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,
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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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,
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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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,
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, 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, 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, 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, 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, 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, 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,
and such continued long values on console.
Also,do I need to remove null before storing it? If yes, how?If now, how do I read this?

Related

Why my oled display suddenly freezes while arduino is running code

I recently tried to make a menu on 128x64 oled display I2C and arduino uno so I found this really good tutorial(https://youtu.be/HVHVkKt-ldc). I wrote code to make menu scroll using joystick than I added a little game, uploaded code to my arduino and it worked well. I played that game on arduino and after three days display started randomly freezing only way to fix that eas to reset the arduino but when i played game it never freezed, display was only freezing when I was scrolling through the menu. By the way I was using u8glib. If you have any questions I'll respond as quickly as possible. Please hel me to solve this problem.
I tried everything: I rewrote logic, I replaced joystick with buttons, I uploaded different programs i just don't know what to do.
here is my code, sorry that it is messy.
#include <U8glib.h>
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST); // Fast I2C / TWI
const int NUM_ITEMS = 5;
// 'icon 1', 16x16px
const unsigned char epd_bitmap_icon_1 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x77, 0x77,
0x7f, 0xff, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'icon 2', 16x16px
const unsigned char epd_bitmap_icon_2 [] PROGMEM = {
0x00, 0x00, 0x01, 0x80, 0x02, 0x40, 0x02, 0xc0, 0x02, 0x40, 0x02, 0xc0, 0x02, 0x40, 0x02, 0xc0,
0x02, 0x40, 0x02, 0xc0, 0x02, 0x40, 0x04, 0x20, 0x06, 0x20, 0x07, 0xe0, 0x03, 0xc0, 0x00, 0x00
};
// 'icon 3', 16x16px
const unsigned char epd_bitmap_icon_3 [] PROGMEM = {
0x00, 0x00, 0x14, 0x00, 0x08, 0x00, 0x11, 0x00, 0x01, 0x0a, 0x01, 0x04, 0x01, 0x0a, 0x01, 0x00,
0x01, 0xf8, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char epd_bitmap_icon_4 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x60, 0x06,
0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char epd_bitmap_icon_5 [] PROGMEM = {
0x1f, 0xf8, 0x1f, 0xf8, 0x10, 0x08, 0x10, 0x08, 0x13, 0xc8, 0x09, 0x90, 0x04, 0x20, 0x02, 0x40,
0x02, 0x40, 0x05, 0xa0, 0x08, 0x10, 0x11, 0x88, 0x11, 0xc8, 0x13, 0xc8, 0x1f, 0xf8, 0x1f, 0xf8
};
const unsigned char epd_bitmap_frame [] PROGMEM = {
0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0,
0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 144)
void setup(void) {
u8g.setColorIndex(1);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(13, INPUT_PULLUP);
Serial.begin(9600);
}
const unsigned char* icons[NUM_ITEMS] = {
epd_bitmap_icon_1,
epd_bitmap_icon_2,
epd_bitmap_icon_3,
epd_bitmap_icon_4,
epd_bitmap_icon_5
};
char menu_items [NUM_ITEMS] [20] = {
{"Distance meter"},
{"Thermometer"},
{"Gyro"},
{"Game"},
{"Timer"}
};
int previous_it;
int selected_it = 0;
int next_it;
int xStick;
int yStick;
unsigned long sec;
char location = "menu";
byte btnC = 0;
boolean btn;
int x_cir = 32;
int y_cir = 64;
void stickValues(){
xStick = analogRead(A0);
yStick = analogRead(A1);
yStick = map(yStick, 0, 1023, -1, 6);
constrain(yStick, -1, 6);
xStick = map(xStick, 0, 1023, -1, 6);
constrain(xStick, -1, 6);
btn = !digitalRead(13);
}
void circle(){
u8g.drawLine(20, 32, 30, 32);
u8g.drawLine(59, 10, 69, 10);
u8g.drawLine(98, 32, 108, 32);
u8g.drawCircle(y_cir, x_cir, 4);
}
void game(){
stickValues();
if (millis() - sec > 50){
if(yStick < 2 && y_cir < 128){
y_cir += 4;
}
if(yStick > 4 && y_cir > 0){
y_cir -= 4;
}
if(xStick < 2 && x_cir > 0){
x_cir -= 4;
}
if(xStick > 4 && x_cir < 64){
x_cir += 4;
}
sec = millis();
}
}
void loop(void){
// logic to select item
stickValues();
if(btnC != 1){
if(xStick < 2 && millis() - sec > 200){
selected_it += 1;
if(selected_it == 4){selected_it = 0;}
sec = millis();
}
if(xStick > 4 && millis() - sec > 200){
selected_it -= 1;
if(selected_it == -1){selected_it = 4;}
sec = millis();
}
}
previous_it = (selected_it - 1);
if (previous_it < 0) {previous_it = 4;} // previous item would be below first = make it the last
next_it = (selected_it + 1);
if (next_it > 4) {next_it = 0;}
// end
// actions to begin the game
if(selected_it == 3 && btnC == 1){
if (millis() - sec > 50){
if(btn == 1){
btnC++;
if(btnC > 1){btnC = 0;}
}
game();
sec = millis();
}
}
// end
//serial things
// Serial.print("btn ");
// Serial.print(btn);
// Serial.print(" btnC ");
// Serial.print(btnC);
// Serial.print(" yStick ");
// Serial.print(yStick);
// Serial.print(" xStick ");
// Serial.print(xStick);
// Serial.print(" selected_it ");
// Serial.print(selected_it);
// Serial.print(" next_it ");
// Serial.println(next_it);
// button counter
if(btn == 1){
btnC++;
if(btnC > 1){btnC = 0;}
}
//end
u8g.firstPage();
do {
// game begin
if(selected_it == 3 && btnC == 1){circle();}
//
// menu begin
if(btnC == 0 ){
//previos item
u8g.setFont(u8g_font_7x14);
u8g.drawStr(26, 15, menu_items[previous_it]);
u8g.drawBitmapP( 4, 2, 16/8, 16, icons[previous_it]);
//selected item
u8g.setFont(u8g_font_7x14B);
u8g.drawStr(26, 37, menu_items[selected_it]);
u8g.drawBitmapP( 4, 24, 16/8, 16, icons[selected_it]);
//next item
u8g.setFont(u8g_font_7x14);
u8g.drawStr(26, 59, menu_items[next_it]);
u8g.drawBitmapP( 4, 46, 16/8, 16, icons[next_it]);
u8g.drawBitmapP( 0, 22, 128/8, 20, epd_bitmap_frame);
}
// menu end
} while( u8g.nextPage() );
}

Why is this arduino esp32 code not working?

I am a beginner to programming
I am trying to program an ESP32 to show Bitcoin and Cardano price on an Adafruit SSD1306
128x64 OLED display based on the youtube video https://youtu.be/1Xas_UCOMvQ,
I want to show more than one crypto currency (bitcoin and cardano) but couldn't find a code for that so tried to do it myself by combining two codes from two guys (sources are mentioned below),
when I tried to run it is showing bitcoin price but for cardano it is showing "null".
Can you tell me why it is not showing cardano price?
code is given below
//Bitcoin and Cardano Ticker
//Modified with codes from Michael Klements original version "https://www.the-diy-life.com/bitcoin-ticker-using-an-esp32-and-oled-display/"
("https://youtu.be/1Xas_UCOMvQ")and Vincent Rubens "https://github.com/xreactx/CryptoTicker/blob/main/CryptoTickerADA.ino"
//to include the Bitcoin logo and IO for the red and green indicator LEDs
#include <Adafruit_SSD1306.h> //Include the required libraries
#include <WiFi.h>
#include <Wire.h>
#include <HTTPClient.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <ArduinoJson.h>
#define SCREEN_WIDTH 128 //Define the OLED display width and height
#define SCREEN_HEIGHT 64
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C //I2C address for display
#define upLED 13
#define downLED 12
Adafruit_SSD1306 display (SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); //Create the display object
const char* ssid = "Your wifi name"; //Set your WiFi network name and password
const char* password = "your wifi password";
const int httpsPort = 443; //Bitcoin price API powered by CoinDesk - https://www.coindesk.com/price/bitcoin
const String url = "http://api.coindesk.com/v1/bpi/currentprice/BTC.json";
const String historyURL = "http://api.coindesk.com/v1/bpi/historical/close.json";
const String cryptoCode = "BTC";
const String url1 = "https://api.coingecko.com/api/v3/simple/price?ids=cardano&vs_currencies=usd&include_24hr_change=true";
//Cardano price API powered by CoinDesk - https://www.coingecko.com/
WiFiClient client; //Create a new WiFi client
HTTPClient http;
String formattedDate; //Create variables to store the date and time
String dayStamp;
String timeStamp;
const unsigned char bitcoinLogo [] PROGMEM = // 'Bitcoin Logo', 128x64px
{
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, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x03, 0xe7, 0xc0, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x03, 0xe7, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x02, 0x24, 0x40, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x02, 0x24, 0x40, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x02, 0x24, 0x40, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x02, 0x24, 0x40, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x02, 0x3c, 0x40, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x07, 0x03, 0xfe, 0x3c, 0x7c, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x1f, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0e, 0x03, 0x00, 0x00, 0x01, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1c, 0x03, 0xf0, 0x3f, 0x80, 0x60, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xf0, 0x3f, 0xe0, 0x20, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x18, 0x30, 0x70, 0x30, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x18, 0x30, 0x10, 0x30, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x18, 0x30, 0x10, 0x30, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x18, 0x30, 0x10, 0x30, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x18, 0x30, 0x30, 0x20, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x18, 0x30, 0xe0, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x3f, 0xc0, 0xc0, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x00, 0x01, 0xc0, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x00, 0x00, 0xf0, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x00, 0x00, 0x38, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x3f, 0xe0, 0x18, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x30, 0xf8, 0x0c, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x18, 0x30, 0x1c, 0x0c, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x18, 0x30, 0x0c, 0x0c, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x18, 0x30, 0x04, 0x0c, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x18, 0x30, 0x0c, 0x0c, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x18, 0x30, 0x0c, 0x0c, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x18, 0x30, 0x38, 0x0c, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0xf0, 0x3f, 0xf0, 0x08, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1c, 0x01, 0xe0, 0x1f, 0x00, 0x18, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x00, 0x00, 0x00, 0x30, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0e, 0x03, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x07, 0x03, 0xfe, 0x3c, 0x7e, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x02, 0x3c, 0x40, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x02, 0x24, 0x40, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x02, 0x24, 0x40, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x02, 0x24, 0x40, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x02, 0x24, 0x40, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x03, 0xe7, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x03, 0xe7, 0xc0, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x03, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 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
};
void setup()
{
Serial.begin(115200); //Start the serial monitor
pinMode(upLED, OUTPUT); //Define the LED pin outputs
pinMode(downLED, OUTPUT);
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) //Connect to the display
{
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Don't proceed, loop forever
}
display.clearDisplay(); //Clear the display
display.setTextColor(SSD1306_WHITE); //Set the text colour to white
display.drawBitmap(0, 0, bitcoinLogo, 128, 64, WHITE); //Display bitmap from array
display.display();
delay(2000);
display.clearDisplay(); //Clear the display
display.setTextSize(1); //Set display parameters
display.setTextColor(WHITE);
display.println("Connecting to WiFi...");
display.display();
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi...");
while (WiFi.status() != WL_CONNECTED) //Connect to the WiFi network
{
delay(500);
Serial.print(".");
}
Serial.println();
display.println("Connected to: "); //Display message once connected
display.print(ssid);
display.display();
delay(1500);
display.clearDisplay();
display.display();
}
void loop()
{
Serial.print("Connecting to "); //Display url on Serial monitor for debugging
Serial.println(url);
http.begin(url);
int httpCode = http.GET(); //Get crypto price from API
StaticJsonDocument<2000> doc;
DeserializationError error = deserializeJson(doc, http.getString());
if (error) //Display error message if unsuccessful
{
Serial.print(F("deserializeJson Failed"));
Serial.println(error.f_str());
delay(2500);
return;
}
Serial.print("HTTP Status Code: ");
Serial.println(httpCode);
String BTCUSDPrice = doc["bpi"]["USD"]["rate_float"].as<String>(); //Store crypto price and update date in local variables
String lastUpdated = doc["time"]["updated"].as<String>();
http.end();
Serial.print("Getting history...");
StaticJsonDocument<2000> historyDoc;
http.begin(historyURL); //Get historical crypto price from API
int historyHttpCode = http.GET();
DeserializationError historyError = deserializeJson(historyDoc, http.getString());
if (historyError) { //Display error message if unsuccessful
Serial.print(F("deserializeJson(History) failed"));
Serial.println(historyError.f_str());
delay(2500);
return;
}
Serial.print("History HTTP Status Code: ");
Serial.println(historyHttpCode);
JsonObject bpi = historyDoc["bpi"].as<JsonObject>();
double yesterdayPrice;
for (JsonPair kv : bpi) {
yesterdayPrice = kv.value().as<double>(); //Store yesterday's crypto price
}
Serial.print("BTCUSD Price: "); //Display current price on serial monitor
Serial.println(BTCUSDPrice.toDouble());
Serial.print("Yesterday's Price: "); //Display yesterday's price on serial monitor
Serial.println(yesterdayPrice);
bool isUp = BTCUSDPrice.toDouble() > yesterdayPrice; //Check whether price has increased or decreased
double percentChange;
String dayChangeString = "24hr. Change: ";
if (isUp) //If price has increased from yesterday
{
percentChange = ((BTCUSDPrice.toDouble() - yesterdayPrice) / yesterdayPrice) * 100;
digitalWrite(upLED, HIGH);
digitalWrite(downLED, LOW);
}
else //If price has decreased from yesterday
{
percentChange = ((yesterdayPrice - BTCUSDPrice.toDouble()) / yesterdayPrice) * 100;
dayChangeString = dayChangeString + "-";
digitalWrite(downLED, HIGH);
digitalWrite(upLED, LOW);
}
Serial.print("Percent Change: "); //Display the percentage change on the serial monitor
Serial.println(percentChange);
display.clearDisplay(); //Clear the OLED display
display.setTextSize(1);
printCenter("BTC/USD", 0, 0); //Display the comparison header
display.setTextSize(2);
printCenter("$" + BTCUSDPrice, 0, 25); //Display the current price
display.setTextSize(1); //Display the change percentage
dayChangeString = dayChangeString + percentChange + "%";
printCenter(dayChangeString, 0, 55);
display.display(); //Execute the new display
display.clearDisplay();
delay(5000); //Execute the new display
Serial.print("Connecting to "); //Display url11 on Serial monitor for debugging
Serial.println(url1);
http.begin(url1);
int httpCode1 = http.GET(); //Get crypto price from API
StaticJsonDocument<2000> doc1;
DeserializationError error1 = deserializeJson(doc, http.getString());
if (error) //Display error message if unsuccessful
{
Serial.print(F("deserializeJson Failed"));
Serial.println(error1.f_str());
delay(2500);
return;
}
Serial.print("HTTP Status Code: ");
Serial.println(httpCode1);
//Get crypto price from API
String ADAUSDPrice = doc1["cardano"]["usd"].as<String>(); //Store crypto price and update date in local variables
String percentChange1 = doc1["cardano"]["usd_24h_change"].as<String>();
percentChange1.remove(4); //Adjust the decimal placement
http.end();
Serial.print("ADAUSD Price: "); //Display current price on serial monitor
bool isup1 = percentChange1 > "0"; //Check whether price has increased or decreased
String dayChange1String = "24hr. Change: ";
if (isup1) //If price has increased from yesterday
{
percentChange1 >= "0";
digitalWrite(upLED, HIGH);
digitalWrite(downLED, LOW);
}
else //If price has decreased from yesterday
{
percentChange1 < "0";
digitalWrite(downLED, HIGH);
digitalWrite(upLED, LOW);
}
Serial.print("Percent Change: "); //Display the percentage change on the serial monitor
Serial.println(percentChange1);
display.clearDisplay(); //Clear the OLED display
display.setTextSize(1);
printCenter("ADA/USD", 0, 0); //Display the comparison header
display.setTextSize(2);
printCenter("$" + ADAUSDPrice, 0, 20); //Display the current price
display.setTextSize(1); //Display the change percentage
dayChange1String = dayChange1String + percentChange1 + "%";
printCenter(dayChange1String, 0, 55);
display.display(); //Execute the new display
display.clearDisplay();
delay(5000);
http.end(); //End the WiFi connection
esp_sleep_enable_timer_wakeup(900000000); //Sleep for 15 minutes
}
void printCenter(const String buf, int x, int y) //Function to centre the current price in the display width
{
int16_t x1, y1;
uint16_t w, h;
display.getTextBounds(buf, x, y, &x1, &y1, &w, &h); //Calculate string width
display.setCursor((x - w / 2) + (128 / 2), y); //Set cursor to print string in centre
display.print(buf); //Display string
}
images are given below
displaying "null" for cardano
for bitcoin its showing prices
The error in the code is that you are parsing the wrong document, for the ADA case. You are parsing the BTC doc instead of the ADA doc. In the following line, you should pass doc1 as parameter, but you are passing the document that was received from the BTC url, doc.
Change
DeserializationError error1 = deserializeJson(doc, http.getString());
to
DeserializationError error1 = deserializeJson(doc1, http.getString());

Custom QQuick3DGeometry does not display

Trying to implement a custom geometry for QtQuick3D:
mycustomgeometry.h:
#ifndef MYCUSTOMGEOMETRY_H
#define MYCUSTOMGEOMETRY_H
#include <QQuick3DGeometry>
class MyCustomGeometry : public QQuick3DGeometry
{
Q_OBJECT
public:
MyCustomGeometry();
virtual ~MyCustomGeometry();
signals:
public slots:
void setData(QByteArray vertexData, QByteArray indexData);
};
#endif // MYCUSTOMGEOMETRY_H
mycustomgeometry.cpp:
#include "mycustomgeometry.h"
#include <QVector3D>
// simulate data coming from my application (should look like a cut cuboid)
static unsigned char vertexData[] = {
0x00, 0x00, 0xe0, 0xb3, 0x8c, 0xca, 0x4c, 0xbd, 0x1c, 0x63, 0x89, 0x3d,
0x00, 0x00, 0x60, 0x35, 0x0c, 0xcf, 0x4c, 0x3d, 0xa4, 0x61, 0x89, 0x3d,
0x64, 0x2e, 0x37, 0xbd, 0xb8, 0xcc, 0x4c, 0xbd, 0x00, 0x2a, 0xb7, 0xbc,
0x68, 0x2d, 0x37, 0xbd, 0xe4, 0xcc, 0x4c, 0x3d, 0xe0, 0x2f, 0xb7, 0xbc,
0x80, 0x2d, 0x37, 0x3d, 0xa4, 0xcb, 0x4c, 0xbd, 0x18, 0x2f, 0x37, 0x3d,
0x80, 0x2e, 0x37, 0x3d, 0xf0, 0xcd, 0x4c, 0x3d, 0x28, 0x2c, 0x37, 0x3d,
0xd8, 0x2c, 0x37, 0x3d, 0xf8, 0xce, 0x4c, 0xbd, 0xa0, 0x61, 0x89, 0xbd,
0xd8, 0x2d, 0x37, 0x3d, 0xa4, 0xca, 0x4c, 0x3d, 0x20, 0x63, 0x89, 0xbd
};
static unsigned char indexData[] = {
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00
};
MyCustomGeometry::MyCustomGeometry()
{
QByteArray v(reinterpret_cast<char*>(::vertexData), sizeof(::vertexData));
QByteArray i(reinterpret_cast<char*>(::indexData), sizeof(::indexData));
setData(v, i);
}
MyCustomGeometry::~MyCustomGeometry()
{
}
void MyCustomGeometry::setData(QByteArray vertexData, QByteArray indexData)
{
clear();
setPrimitiveType(PrimitiveType::Triangles);
addAttribute(Attribute::PositionSemantic, 0, Attribute::F32Type);
addAttribute(Attribute::IndexSemantic, 0, Attribute::U32Type);
addAttribute(Attribute::NormalSemantic, 0, Attribute::F32Type);
setVertexData(vertexData);
setIndexData(indexData);
setStride(sizeof(float) * 3);
QVector3D boundsMin, boundsMax;
auto vertices = reinterpret_cast<const float*>(vertexData.constData());
for(size_t i = 0; i < vertexData.length() / sizeof(float); i += 3)
{
for(size_t j = 0; j < 3; j++)
{
boundsMin[j] = (std::min(vertices[i + j], i == 0 ? vertices[i + j] : boundsMin[j]));
boundsMax[j] = (std::max(vertices[i + j], i == 0 ? vertices[i + j] : boundsMax[j]));
}
}
setBounds(boundsMin, boundsMax);
}
main.qml:
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick3D 1.15
import QtQuick3D.Helpers 1.15
import QtQuick.Controls 2.15
import MyCustomGeometry 1.0
Window {
id: mainWindow
width: 400
height: 300
visible: true
flags: Qt.Tool
title: qsTr("3D demo")
View3D {
id: view
anchors.fill: parent
camera: camera
renderMode: View3D.Overlay
PerspectiveCamera {
id: camera
position: Qt.vector3d(0, 200, 300)
eulerRotation.x: -30
}
WasdController {
controlledObject: camera
mouseEnabled: true
}
DirectionalLight {
eulerRotation.x: -30
}
Model {
id: cube
objectName: "cube"
visible: true
position: Qt.vector3d(-100, 0, 0)
scale: Qt.vector3d(slider.k, slider.k, slider.k)
source: "#Cube"
materials: [DefaultMaterial {diffuseColor: "red"}]
eulerRotation.y: 90
}
Model {
id: sphere
objectName: "sphere"
visible: true
position: Qt.vector3d(100, 0, 0)
scale: Qt.vector3d(slider.k, slider.k, slider.k)
//source: "#Sphere"
geometry: MyCustomGeometry {}
materials: [DefaultMaterial {diffuseColor: "blue"}]
eulerRotation.y: 90
}
}
Slider {
id: slider
property real k: Math.pow(10, slider.value)
from: -3; to: 6; value: 3
}
}
The cube, and the sphere (when commenting geometry: and uncommenting source:) display correctly.
But the model with the custom geometry does not.
I tried also with 16-bit integers as indices, but got the same result.
Edit: tested on Qt 6.0.0 and it works, so it is a problem limited to Qt 5.15.2
It works on Qt 5 too if setting the name property, as per QTBUG-89420:
MyCustomGeometry::MyCustomGeometry()
{
QByteArray v(reinterpret_cast<char*>(::vertexData), sizeof(::vertexData));
QByteArray i(reinterpret_cast<char*>(::indexData), sizeof(::indexData));
setData(v, i);
setName("MyCustomGeometry");
}

arduino graphic display clear display doesn't work

I am using a Arduino UNO with a c-control programmable graphic display.
I used the documentation of Franzis Maker Kit Grafikdisplays programmieren TURN ON YOUR CREATIVITY .
Display: DXDCG12864-4330 Displaycontroller: ST7564
My code is:
#include "TextDisplay.h"
int i=1;
TextDisplay display = TextDisplay();
void setup() {
display.init(25);
}
void loop() {
char buffer[40];
display.clear();
display.println("ABCD");
sprintf(buffer, " Dw2: %05d", i);
display.println(buffer);
delay(2000);
i++;
}
The problem is that the lines get printed beneath each other and that the display.clear() doesn't clean the display. The display shows after 2 loops:
ABCD
Dw2: 1
ABCD
Dw2: 2
instant of :
ABCD
Dw2: 2
TextDisplay.h:
#ifndef _TEXTDISPLAY_H_
#define _TEXTDISPLAY_H_
#include "Display.h"
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class TextDisplay {
public:
TextDisplay() {};
void init(byte contrast);
void println(const char* string);
void print(const char string);
void clear(void);
byte getLastCharPosition(byte line);
void writeTextBuffer();
private:
Display lcd;
byte textBuffer[8][22];
byte curserPositionY, curserPositionX;
};
#endif
TextDisplay.cpp:
#include "TextDisplay.h"
#include "Display.h"
#include "Font.h"
void TextDisplay::init(byte contrast) {
lcd = Display();
lcd.init(contrast);
lcd.clearDisplayRAM();
lcd.setPageAddress(0);
lcd.setColumnAddress(0);
curserPositionY = 0;
curserPositionX = 0;
textBuffer[MAX_CHARACTERS_Y][MAX_CHARACTERS_X];
}
void TextDisplay::println(const char* string) {
int position = 0;
while (string[position]) {
char character = string[position];
print(character);
string++;
}
print(13);
}
void TextDisplay::clear(void) {
print(255);
}
void TextDisplay::print(char character) {
switch (character) {
case 255:
for (byte y=0; y<MAX_CHARACTERS_Y; y++) {
for (byte x=0; x<MAX_CHARACTERS_X; x++) {
textBuffer[y][x] = 0;
}
}
writeTextBuffer();
curserPositionY = 0;
curserPositionX = 0;
break;
case 127: //Delete (Putty Backspace)
if (curserPositionX == 0 && curserPositionY > 0) {
curserPositionY--;
curserPositionX = getLastCharPosition(curserPositionY);
textBuffer[curserPositionY][curserPositionX] = 0;
}
else if (curserPositionX > 0) {
curserPositionX--;
textBuffer[curserPositionY][curserPositionX] = 0;
}
else {
}
break;
case 13: //CR
if (curserPositionY < MAX_CHARACTERS_Y-1) {
curserPositionY++;
curserPositionX = 0;
}
break;
default:
if (curserPositionX < MAX_CHARACTERS_X) {
textBuffer[curserPositionY][curserPositionX] = character;
curserPositionX++;
}
else if (curserPositionY < MAX_CHARACTERS_Y-1) {
curserPositionY++;
curserPositionX = 0;
textBuffer[curserPositionY][curserPositionX] = character;
curserPositionX++;
}
break;
}
writeTextBuffer();
}
byte TextDisplay::getLastCharPosition(byte line) {
for (byte x=0; x<MAX_CHARACTERS_X; x++) {
if(textBuffer[line][x] == 0) {
return (x!=0) ? x : 0;
}
}
return MAX_CHARACTERS_X-1;
}
void TextDisplay::writeTextBuffer() {
for (byte y=0; y<MAX_CHARACTERS_Y; y++) {
lcd.setPageAddress(y);
lcd.setColumnAddress(0);
for (byte x=0; x<MAX_CHARACTERS_X; x++) {
int position = textBuffer[y][x] * CHARACTER_WIDTH;
for (byte i=0; i<CHARACTER_WIDTH; i++) {
lcd.writeData(pgm_read_byte(font7x5 + position++));
}
}
}
}
Font.h:
#define CHARACTER_WIDTH 6
#define MAX_CHARACTERS_X 22
#define MAX_CHARACTERS_Y 8
const PROGMEM byte font7x5[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char NULL
0x3E, 0x55, 0x51, 0x55, 0x3E, 0x00, // Code for char
0x3E, 0x6B, 0x6F, 0x6B, 0x3E, 0x00, // Code for char
0x0E, 0x1F, 0x3E, 0x1F, 0x0E, 0x00, // Code for char
0x08, 0x1C, 0x3E, 0x1C, 0x08, 0x00, // Code for char
0x98, 0x9B, 0xFF, 0x9B, 0x98, 0x00, // Code for char
0x18, 0x5E, 0x7F, 0x5E, 0x18, 0x00, // Code for char
0x00, 0x08, 0x1C, 0x08, 0x00, 0x00, // Code for char
0x7F, 0x77, 0x63, 0x77, 0x7F, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x30, 0x48, 0x48, 0x3E, 0x07, 0x00, // Code for char
0x06, 0x29, 0x79, 0x29, 0x06, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x60, 0x7E, 0x06, 0x33, 0x3F, 0x00, // Code for char
0x49, 0x3E, 0x63, 0x3E, 0x49, 0x00, // Code for char
0x08, 0x08, 0x7F, 0x08, 0x08, 0x00, // Code for char
0x08, 0x1C, 0x3E, 0x7F, 0x00, 0x00, // Code for char
0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, // Code for char
0x00, 0x5F, 0x00, 0x5F, 0x00, 0x00, // Code for char
0x06, 0x0F, 0x7F, 0x00, 0x7F, 0x00, // Code for char
0x08, 0x08, 0x0F, 0x08, 0x08, 0x00, // Code for char
0x08, 0x08, 0x78, 0x08, 0x08, 0x00, // Code for char
0x00, 0x08, 0x08, 0x7F, 0x00, 0x00, // Code for char
0x04, 0x02, 0x7F, 0x02, 0x04, 0x00, // Code for char
0x00, 0x7F, 0x08, 0x08, 0x00, 0x00, // Code for char
0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, // Code for char
0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, // Code for char !
0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // Code for char "
0x74, 0x1C, 0x77, 0x1C, 0x17, 0x00, // Code for char #
0x24, 0x4A, 0xFF, 0x52, 0x24, 0x00, // Code for char $
0x43, 0x33, 0x08, 0x66, 0x61, 0x00, // Code for char %
0x36, 0x49, 0x55, 0x22, 0x50, 0x00, // Code for char &
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // Code for char '
0x00, 0x00, 0x3E, 0x41, 0x00, 0x00, // Code for char (
0x00, 0x00, 0x41, 0x3E, 0x00, 0x00, // Code for char )
0x00, 0x0A, 0x04, 0x0A, 0x00, 0x00, // Code for char *
0x00, 0x08, 0x1C, 0x08, 0x00, 0x00, // Code for char +
0x00, 0x00, 0xA0, 0x60, 0x00, 0x00, // Code for char ,
0x00, 0x08, 0x08, 0x08, 0x00, 0x00, // Code for char -
0x00, 0x00, 0x60, 0x60, 0x00, 0x00, // Code for char .
0x00, 0x60, 0x1C, 0x03, 0x00, 0x00, // Code for char /
0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, // Code for char 0
0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, // Code for char 1
0x42, 0x61, 0x51, 0x49, 0x46, 0x00, // Code for char 2
0x22, 0x41, 0x49, 0x49, 0x36, 0x00, // Code for char 3
0x1C, 0x13, 0x10, 0x78, 0x10, 0x00, // Code for char 4
0x4F, 0x49, 0x49, 0x49, 0x31, 0x00, // Code for char 5
0x3E, 0x49, 0x49, 0x49, 0x32, 0x00, // Code for char 6
0x01, 0x01, 0x71, 0x09, 0x07, 0x00, // Code for char 7
0x36, 0x49, 0x49, 0x49, 0x36, 0x00, // Code for char 8
0x26, 0x49, 0x49, 0x49, 0x3E, 0x00, // Code for char 9
0x00, 0x00, 0x6C, 0x6C, 0x00, 0x00, // Code for char :
0x00, 0x00, 0xAC, 0x6C, 0x00, 0x00, // Code for char ;
0x00, 0x08, 0x14, 0x22, 0x00, 0x00, // Code for char <
0x00, 0x14, 0x14, 0x14, 0x00, 0x00, // Code for char =
0x00, 0x22, 0x14, 0x08, 0x00, 0x00, // Code for char >
0x02, 0x01, 0x51, 0x09, 0x06, 0x00, // Code for char ?
0x3E, 0x5D, 0x5D, 0x51, 0x5E, 0x00, // Code for char #
0x7E, 0x09, 0x09, 0x09, 0x7E, 0x00, // Code for char A
0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, // Code for char B
0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, // Code for char C
0x7F, 0x41, 0x41, 0x22, 0x1C, 0x00, // Code for char D
0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, // Code for char E
0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, // Code for char F
0x3E, 0x41, 0x41, 0x51, 0x32, 0x00, // Code for char G
0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, // Code for char H
0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, // Code for char I
0x00, 0x20, 0x40, 0x3F, 0x00, 0x00, // Code for char J
0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, // Code for char K
0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, // Code for char L
0x7F, 0x02, 0x0C, 0x02, 0x7F, 0x00, // Code for char M
0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, // Code for char N
0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, // Code for char O
0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, // Code for char P
0x3E, 0x41, 0x41, 0x21, 0x5E, 0x00, // Code for char Q
0x7F, 0x09, 0x09, 0x09, 0x76, 0x00, // Code for char R
0x26, 0x49, 0x49, 0x49, 0x32, 0x00, // Code for char S
0x01, 0x01, 0x7F, 0x01, 0x01, 0x00, // Code for char T
0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, // Code for char U
0x03, 0x1C, 0x60, 0x1C, 0x03, 0x00, // Code for char V
0x1F, 0x60, 0x18, 0x60, 0x1F, 0x00, // Code for char W
0x63, 0x14, 0x08, 0x14, 0x63, 0x00, // Code for char X
0x03, 0x04, 0x78, 0x04, 0x03, 0x00, // Code for char Y
0x61, 0x51, 0x49, 0x45, 0x43, 0x00, // Code for char Z
0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, // Code for char [
0x00, 0x03, 0x1C, 0x60, 0x00, 0x00, // Code for char BackSlash
0x00, 0x41, 0x41, 0x7F, 0x00, 0x00, // Code for char ]
0x00, 0x06, 0x01, 0x06, 0x00, 0x00, // Code for char ^
0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // Code for char _
0x00, 0x00, 0x01, 0x02, 0x00, 0x00, // Code for char `
0x38, 0x44, 0x44, 0x44, 0x7C, 0x00, // Code for char a
0x7F, 0x44, 0x44, 0x44, 0x38, 0x00, // Code for char b
0x38, 0x44, 0x44, 0x44, 0x28, 0x00, // Code for char c
0x38, 0x44, 0x44, 0x44, 0x7F, 0x00, // Code for char d
0x38, 0x54, 0x54, 0x54, 0x58, 0x00, // Code for char e
0x00, 0x04, 0x7E, 0x05, 0x00, 0x00, // Code for char f
0x18, 0xA4, 0xA4, 0xA4, 0x7C, 0x00, // Code for char g
0x7F, 0x04, 0x04, 0x04, 0x78, 0x00, // Code for char h
0x00, 0x00, 0x7D, 0x00, 0x00, 0x00, // Code for char i
0x00, 0x40, 0x3D, 0x00, 0x00, 0x00, // Code for char j
0x7F, 0x20, 0x10, 0x28, 0x44, 0x00, // Code for char k
0x00, 0x00, 0x3F, 0x40, 0x00, 0x00, // Code for char l
0x78, 0x04, 0x78, 0x04, 0x78, 0x00, // Code for char m
0x04, 0x78, 0x04, 0x04, 0x78, 0x00, // Code for char n
0x38, 0x44, 0x44, 0x44, 0x38, 0x00, // Code for char o
0xF8, 0x44, 0x44, 0x44, 0x38, 0x00, // Code for char p
0x38, 0x44, 0x44, 0x44, 0xF8, 0x00, // Code for char q
0x00, 0x7C, 0x08, 0x04, 0x04, 0x00, // Code for char r
0x48, 0x54, 0x54, 0x54, 0x24, 0x00, // Code for char s
0x00, 0x04, 0x3F, 0x44, 0x00, 0x00, // Code for char t
0x3C, 0x40, 0x40, 0x40, 0x7C, 0x00, // Code for char u
0x0C, 0x30, 0x40, 0x30, 0x0C, 0x00, // Code for char v
0x1C, 0x60, 0x1C, 0x60, 0x1C, 0x00, // Code for char w
0x44, 0x28, 0x10, 0x28, 0x44, 0x00, // Code for char x
0x44, 0x48, 0x30, 0x08, 0x04, 0x00, // Code for char y
0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, // Code for char z
0x00, 0x08, 0x36, 0x41, 0x00, 0x00, // Code for char {
0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, // Code for char |
0x00, 0x41, 0x36, 0x08, 0x00, 0x00, // Code for char }
0x08, 0x04, 0x08, 0x08, 0x04, 0x00, // Code for char ~
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x14, 0x3E, 0x55, 0x55, 0x41, 0x00, // Code for char €
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0xA0, 0x60, 0x00, 0x00, // Code for char ‚
0x00, 0x84, 0x7E, 0x05, 0x01, 0x00, // Code for char ƒ
0xA0, 0x60, 0x00, 0xA0, 0x60, 0x00, // Code for char „
0x40, 0x00, 0x40, 0x00, 0x40, 0x00, // Code for char …
0x04, 0x04, 0xFF, 0x04, 0x04, 0x00, // Code for char †
0x24, 0x24, 0xFF, 0x24, 0x24, 0x00, // Code for char ‡
0x00, 0x02, 0x01, 0x02, 0x00, 0x00, // Code for char ˆ
0x63, 0x13, 0x6C, 0x63, 0x60, 0x60, // Code for char ‰
0x48, 0x55, 0x56, 0x55, 0x24, 0x00, // Code for char Š
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ‹
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Œ
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ž
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ‘
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ’
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char “
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ”
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char •
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char –
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char —
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ˜
0x01, 0x07, 0x01, 0x07, 0x03, 0x07, // Code for char ™
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char š
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ›
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char œ
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ž
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ÿ
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¡
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¢
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char £
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¤
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¥
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¦
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char §
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¨
0x7E, 0x81, 0xBD, 0xA5, 0x81, 0x7E, // Code for char ©
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ª
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char «
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¬
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ­
0x7E, 0x81, 0xBD, 0x9D, 0xA1, 0x7E, // Code for char ®
0x01, 0x01, 0x01, 0x01, 0x01, 0x00, // Code for char ¯
0x00, 0x02, 0x05, 0x02, 0x00, 0x00, // Code for char °
0x00, 0x48, 0x5C, 0x48, 0x00, 0x00, // Code for char ±
0x00, 0x09, 0x0D, 0x0A, 0x00, 0x00, // Code for char ²
0x00, 0x09, 0x0D, 0x0F, 0x00, 0x00, // Code for char ³
0x00, 0x00, 0x02, 0x01, 0x00, 0x00, // Code for char ´
0xFC, 0x40, 0x40, 0x40, 0x3C, 0x00, // Code for char µ
0x06, 0x0F, 0xFF, 0x01, 0xFF, 0x01, // Code for char ¶
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ·
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¸
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¹
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char º
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char »
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¼
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ½
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¾
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ¿
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char À
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Á
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Â
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ã
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ä
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Å
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Æ
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ç
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char È
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char É
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ê
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ë
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ì
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Í
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Î
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ï
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ð
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ñ
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ò
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ó
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ô
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Õ
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ö
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ×
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ø
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ù
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ú
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Û
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ü
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Ý
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Þ
0xFE, 0x49, 0x49, 0x56, 0x20, 0x00, // Code for char ß
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char à
0xFE, 0x49, 0x49, 0x56, 0x20, 0x00, // Code for char á
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char â
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ã
0x38, 0x45, 0x44, 0x45, 0x7C, 0x00, // Code for char ä
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char å
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char æ
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ç
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char è
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char é
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ê
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ë
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ì
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char í
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char î
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ï
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ð
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ñ
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ò
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ó
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ô
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char õ
0x30, 0x4A, 0x48, 0x4A, 0x30, 0x00, // Code for char ö
0x08, 0x08, 0x2A, 0x08, 0x08, 0x00, // Code for char ÷
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ø
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ù
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ú
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char û
0x38, 0x42, 0x40, 0x42, 0x78, 0x00, // Code for char ü
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ý
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char þ
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ÿ
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Code for char
};
Display.h
Can someone tell me whats wrong?
Thanks in advance.
Download BugAVRgcc_Char.zip from http://tiny.systems/categorie/lcdProjekt/FragenAntworten.html and extract the new libraries

SSD1306, DIGISparkOLED not working with teensy3.2

OLED display is not working with teensy3.2 board, but it is working fine with arduino UNO with the same code as below:
#include <U8glib.h>
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK); // Display which does
not send AC
int frame=0;
const uint8_t frame1[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFE, 0x00, 0x3F, 0xFF, 0xFF, 0x00,
0x3F, 0xFF, 0xFF, 0x80,
0x30, 0x00, 0x01, 0x80, 0x33, 0xFF, 0x81, 0xC0, 0x33, 0xFF, 0x81, 0xE0,
0x33, 0xFF, 0x81, 0xE0,
0x33, 0xFF, 0x81, 0xE0, 0x33, 0xFF, 0x81, 0xE0, 0x33, 0xFF, 0x81, 0xE0,
0x33, 0xFF, 0x81, 0xE0,
0x33, 0xFF, 0x81, 0xE0, 0x33, 0xFF, 0x81, 0xC0, 0x30, 0x00, 0x01, 0x80,
0x3F, 0xFF, 0xFF, 0x80,
0x3F, 0xFF, 0xFF, 0x00, 0x0F, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const uint8_t frame2[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x0F, 0x00,
0x00, 0x09, 0x80, 0x00,
0x08, 0xE0, 0x00, 0x08, 0x38, 0x00, 0x08, 0x1C, 0x0C, 0x08, 0x0F, 0x06,
0x08, 0x1C, 0x03, 0x88,
0x70, 0x00, 0xC8, 0xE0, 0x00, 0x79, 0x80, 0x00, 0x1E, 0x00, 0x00, 0x1E,
0x00, 0x00, 0x79, 0x80,
0x00, 0xC8, 0xE0, 0x03, 0x88, 0x70, 0x06, 0x08, 0x1C, 0x0C, 0x08, 0x0F,
0x00, 0x08, 0x1C, 0x00,
0x08, 0x38, 0x00, 0x08, 0xE0, 0x00, 0x09, 0xC0, 0x00, 0x0F, 0x00, 0x00,
0x0C, 0x00, 0x00, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
};
const uint8_t frame3 [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x01, 0x80, 0x00,
0x00, 0x01, 0xC0, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00,
0x00, 0x03, 0xC0, 0x00,
0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x02, 0x40, 0x00,
0x00, 0x06, 0x40, 0x00,
0x00, 0x06, 0x60, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x06, 0x60, 0x00,
0x00, 0x04, 0x60, 0x00,
0x00, 0x0C, 0x60, 0x00, 0x00, 0x0C, 0x60, 0x00, 0x07, 0xFC, 0x61, 0xFC,
0x07, 0xF8, 0x33, 0xFC,
0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x33, 0x00,
0x00, 0x00, 0x33, 0x00,
0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x3E, 0x00,
0x00, 0x00, 0x1E, 0x00,
0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x00,
0x00, 0x00, 0x1C, 0x00,
0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const uint8_t frame4[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xE0, 0x00, 0x00, 0x01, 0xFF,
0xF8, 0x00, 0x00, 0x07,
0xFF, 0xFE, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x00, 0x00, 0x3F, 0xFF, 0xFF,
0x80, 0x00, 0x7F, 0xFF,
0xFF, 0xC0, 0x00, 0xFF, 0xFF, 0xFF, 0xF0, 0x01, 0xFF, 0xFF, 0xFF, 0xF0,
0x01, 0xFF, 0xFF, 0xFE,
0xF8, 0x03, 0xFF, 0xFF, 0xFC, 0x78, 0x03, 0xFF, 0xFF, 0xF8, 0x7C, 0x07,
0xFF, 0xFF, 0xF0, 0xFC,
0x07, 0xFF, 0xFF, 0xE1, 0xFC, 0x0F, 0xFF, 0xFF, 0xC3, 0xFE, 0x0F, 0xFF,
0xFF, 0x87, 0xFE, 0x0F,
0xFF, 0xFF, 0x0F, 0xFE, 0x0F, 0xF3, 0xFE, 0x1F, 0xFE, 0x0F, 0xE1, 0xFC,
0x3F, 0xFE, 0x0F, 0xE0,
0xF8, 0x7F, 0xFE, 0x0F, 0xF0, 0x70, 0xFF, 0xFE, 0x0F, 0xF8, 0x21, 0xFF,
0xFE, 0x0F, 0xFC, 0x03,
0xFF, 0xFE, 0x07, 0xFE, 0x07, 0xFF, 0xFC, 0x07, 0xFF, 0x0F, 0xFF, 0xFC,
0x07, 0xFF, 0x9F, 0xFF,
0xFC, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x01, 0xFF, 0xFF, 0xFF, 0xF8, 0x01,
0xFF, 0xFF, 0xFF, 0xF0,
0x00, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x7F, 0xFF, 0xFF, 0xC0, 0x00, 0x3F,
0xFF, 0xFF, 0x80, 0x00,
0x1F, 0xFF, 0xFF, 0x00, 0x00, 0x0F, 0xFF, 0xFE, 0x00, 0x00, 0x03, 0xFF,
0xF8, 0x00, 0x00, 0x00,
0x7F, 0xC0, 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,
};
void setup(void) {
}
void loop(void) {
u8g.firstPage();
do{
draw();
}while(u8g.nextPage());
frame++;
if(frame == 13)
frame=0;
delay(1000);
}
void draw(){
if(frame == 0 )
{ u8g.drawBitmapP(0,0,4,20,frame1);
u8g.drawBitmapP(103,0,3.5,28, frame2);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(20,45,"11:45");
u8g.setFont(u8g_font_helvB12);
u8g.drawStr(100,60,"AM");
}
if(frame == 1 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(0,20,"Heart Rate");
u8g.setFont(u8g_font_helvR24);
u8g.drawStr(25,60,"75");
u8g.setFont(u8g_font_helvB12);
u8g.drawStr(90,60,"BPM");
}
if(frame == 2 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(50,58,"10");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 3 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"9");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 4 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"8");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 5 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"7");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 6 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"6");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 7 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"5");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 8 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"4");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 9 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"3");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 10 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"2");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 11 )
{u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"1");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 12)
{u8g.drawBitmapP(45,0,5.375,43, frame4);
u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(45,58,"Done");
}
}
Their are no compiling errors. The OLED is not even turning on. AND on scanning the address comes out to be 0X3C.I have searched a lot on google but i think theirs and issue in I2C communication.
Please help me out.
#vasu Hi I had the same problem but please also check for any hardware faults before following my answer.
The oled display I bought only had VCC-GND-SCL-SDA. So I don't have a reset PIN here.
But the oled library initially tries to pull the reset PIN high on startup. Since I don't have a reset pin, it sits there and waits for a reset HIGH. So in order to initialise your oled display without reset pin then try this in your Arduino sketch file
//1-->Manually set HIGH to digitally assigned reset pin
pinMode(A4, OUTPUT); //A4 is reset pin assigned programmatically (for example)
digitalWrite(A4, HIGH);
//2-->Try changing your init to this
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);
//As this will be the right one to define from the user manual shown in the link
//https://reprap.org/forum/file.php?267,file=54605
Try the above and let me know how it went.
Cheers

Resources