Screen


t90add

Recommended Posts

Right, we can do both! 

 

So here is what I did, and what I have running via Uart.

 

1) Start the WINGAnalog xise file. 

 

2) Delete one of the wishbones

 

3) Add the UART wishbone to the previously deleted site.

 

Note the wishbone site number (mine is 6).

 

4) generate the bit file

 

5) load to SPI flash 

 

6) Start zapuino with analogWING example. (We plan on taking a reading from the wing, then plotting it onto the display/screen).

#include "SPIADC.h"#include "SPI.h"int CurVal; // Analog valueint i=0; // for indexing loopHardwareSerial MySerial1(6); // within the paranthesis, place the wishbone for the UART (mine is 6).void setup() {  // put your setup code here, to run once:    //tx goes to pin 0  //rx goes to pin 1  Serial.begin(9600);  MySerial1.begin(9600); // What I called the uart.   analog.begin(CS(WCH4),WISHBONESLOT(5),ADCBITS(SPIADC_12BIT));  delay(5000); // Delay a bit for the screen to start running}void loop() {  // Inorder for the screen to recognize a command, it needs to be sent via MySerial1.write(SOME HEX NUMBER). Note the command sheet that accomponies the screen for commands ect.. // To Clear Screen  /*  Serial.println("Sending");    MySerial1.write(0xFF);    MySerial1.write(0xD7);  Serial.println("Sending back");*/  // Uncomment this after sending any commands to the screen, so that you can see if it was accpeted by the screen (i.e. it should return '6' or '0x06')/*if (MySerial1.available() ){   Serial.println(MySerial1.read());}       *//*// Putting it in portrait reverse (corresponds to 0x03, the last bit). MySerial1.write(0xFF);MySerial1.write(0x68);MySerial1.write((byte)0x00);MySerial1.write((byte)0x03);*//* Putting 1 char as in hex which is displayed as char on screen (NOT INT)  Serial.println("Sending 2");    MySerial1.write(0xFF);    MySerial1.write(0xFE);    MySerial1.write((byte)0x00);    MySerial1.write(0x39);            */ //Putting string into screen (I think it says Hello)// Alternativly, you could send MySerial.print('Hello') <-- I think that works too. /*      MySerial1.write((byte)0x00);    MySerial1.write(0x06);    MySerial1.write(0x48);    MySerial1.write(0x65);    MySerial1.write(0x6C);    MySerial1.write(0x6C);    MySerial1.write(0x6F);   MySerial1.write((byte)0x00); */       // Drawing a Line. (x1,y1) to (x2,y2) then color. /*  Serial.println("Sending 2");    MySerial1.write(0xFF);    MySerial1.write(0xD2);    MySerial1.write((byte)0x00);    MySerial1.write(0x0A);    MySerial1.write((byte)0x00);    MySerial1.write(0x0F);    MySerial1.write((byte)0x00);    MySerial1.write(0x28);    MySerial1.write((byte)0x00);    MySerial1.write(0x3C);    MySerial1.write(0x04);    MySerial1.write(0x10);     */

What to do next:

 

1) build loop to index and store values from the adc to an array.

 

2) index through the values and plot as (index, y1) to (index ++, y1).

 

 

For some reason, it does not plot it correctly? Also it does it very slowly. 

Link to comment
Share on other sites

Looks like good progress! I connected the ulcd-144-g2 to my Papilio last night but got stuck because there is a really old PMMC loaded on my display. I had to bite the bullet and order one of their programming cables to update the pmmc.

 

Good news is it is coming from Sparkfun which is just 30 minutes away from me. So should arrive quickly.

Link to comment
Share on other sites

Nice!

 

 

Well I got the code working!

 

Turns out my big issue was having the screen connected to the board whilst the papilio was being updated with arduino code. So keep that in mind.

 

Code is a little buggy (plotting too many pixels, about 70 readings are lost, but whatever lol). 

#include "SPIADC.h"#include "SPI.h"int CurVal; // Analog valueint i=1,j=2; // for indexing loopint y[200];HardwareSerial MySerial1(6); // within the paranthesis, place the wishbone for the UART (mine is 6).void setup() {  // put your setup code here, to run once:    //tx goes to pin 0  //rx goes to pin 1  MySerial1.begin(9600); // What I called the uart.   Serial.begin(9600);   analog.begin(CS(WCH4),WISHBONESLOT(5),ADCBITS(SPIADC_12BIT));  delay(5000); // Delay a bit for the screen to start running/*MySerial1.write(0xFF);MySerial1.write(0x68);MySerial1.write((byte)0x00);MySerial1.write((byte)0x03);*/  }void loop() {      if (MySerial1.available()){// Inorder for the screen to recognize a command, it needs to be sent via MySerial1.write(SOME HEX NUMBER). Note the command sheet that accomponies the screen for commands ect..     MySerial1.write((byte)0x00);    MySerial1.write(0x06);    MySerial1.write(0x48);    MySerial1.write(0x65);    MySerial1.write(0x6C);    MySerial1.write(0x6C);    MySerial1.write(0x6F);   MySerial1.write((byte)0x00); }      delay(2000);// To Clear Screen      MySerial1.write(0xFF);    MySerial1.write(0xD7);  // Uncomment this after sending any commands to the screen, so that you can see if it was accpeted by the screen (i.e. it should return '6' or '0x06')/*if (MySerial1.available() ){   Serial.println(MySerial1.read());}       *//*// Putting it in portrait reverse (corresponds to 0x03, the last bit). MySerial1.write(0xFF);MySerial1.write(0x68);MySerial1.write((byte)0x00);MySerial1.write((byte)0x03);*//* Putting 1 char as in hex which is displayed as char on screen (NOT INT)  Serial.println("Sending 2");    MySerial1.write(0xFF);    MySerial1.write(0xFE);    MySerial1.write((byte)0x00);    MySerial1.write(0x39);            */ //Putting string into screen (I think it says Hello)// Alternativly, you could send MySerial.print('Hello') <-- I think that works too. /*      MySerial1.write((byte)0x00);    MySerial1.write(0x06);    MySerial1.write(0x48);    MySerial1.write(0x65);    MySerial1.write(0x6C);    MySerial1.write(0x6C);    MySerial1.write(0x6F);   MySerial1.write((byte)0x00); */       // Drawing a Line. (x1,y1) to (x2,y2) then color. /*    MySerial1.write(0xFF);    MySerial1.write(0xD2);    MySerial1.write((byte)0x00);    MySerial1.write(0x0A);    MySerial1.write((byte)0x00);    MySerial1.write(0x0F);    MySerial1.write((byte)0x00);    MySerial1.write(0x28);    MySerial1.write((byte)0x00);    MySerial1.write(0x3C);    MySerial1.write(0x04);    MySerial1.write(0x10);     */// The below loop is for aquiring data and building it as an array//for (i=0; i<100; i++){//Serial.println(analog.read(0));}//    Serial.println(analog.read(0));//MySerial1.flush();// To draw a linefor (i=0;i<200;i++){  y[i]=analog.read(0)/50;delay(50);}i=0;j=1;while (j< 190) {    //    MySerial1.write(0xFF);//    MySerial1.write(0xD2);        //put pixel            MySerial1.write(0xFF);    MySerial1.write(0xCB);            MySerial1.write((byte)0x00);    MySerial1.write(i);    MySerial1.write((byte)0x00);    MySerial1.write(y[i]);          //  MySerial1.write((byte)0x00);  //  MySerial1.write(j);  //  MySerial1.write((byte)0x00); //   MySerial1.write(y[j]);    MySerial1.write(0x04);    MySerial1.write(0x10);//     Serial.println(y[i]);//     Serial.println(y[j]);Serial.print("Y[i]=");Serial.print(y[i]);Serial.print(", Count i=");Serial.print(i);Serial.print(", Rx = ");Serial.println(MySerial1.read());/*Serial.println(" ");Serial.print("y=");Serial.print(y[i]);Serial.print(",i=");Serial.print(i);Serial.println("");Serial.print("y=");Serial.print(y[j]);Serial.print(",j=");Serial.print(j);Serial.println("-----");*///MySerial1.flush(); i=i+1; j=j+1; /* if (i >8){    MySerial1.write((byte)0x00);    MySerial1.write(0x06);    MySerial1.write(0x48);    MySerial1.write(0x65);    MySerial1.write(0x6C);    MySerial1.write(0x6C);    MySerial1.write(0x6F);   MySerial1.write((byte)0x00); } */ } MySerial1.flush(); delay(200);}// delay(100);}
Link to comment
Share on other sites

  • 3 years later...

Archived

This topic is now archived and is closed to further replies.