Close

Prototype under Development

A project log for Open Source Cell Phone

A completely open hardware and open source software cell phone

hugh-darrowHugh Darrow 08/20/2014 at 06:240 Comments

    So I had ordered a Due, 4.3" TFT touch screen, and RA8875 driver from adafruit that arrived today 8/19/2014, and quickly got started on the programming and such here is what it looks like so far with the background cut out to make the components easier to see

    I've got the display up and running aside from the GPRS shield that still works but the two are not working together yet. I spent most of the day writing, rewriting and such. I also learned a great deal more c++, and byte registers and such, and improved the library from adafruit to include a rotate text function now defined as textRotate(boolean), cool ay. I'm having a blast with this project as I've never taken any classes nor learned a programming language so I'm teaching myself as I go along. I've created a new prototype project sketch and will include the new libraries and references on the github site. In order to use the Due you'll need arduino-ide-beta which currently is 1.5.7 which i have included the msi in the github as well.

   Now for the what I've done and why, first adafruit was kind enough to include libraries to the RA8875 the .cpp(c++) file and the .h(header) file, thank you for that. by examining the header file you can quickly see all the different functions available that is written. The files on the github are the ones I've modified to include the rotate text function, check out the modifications to see how I implemented them. In the datasheet to the RA8875 page 20 you'll it defines that function as Reg(22h) with bit 4 being the flipper, 0 normal 1 for 90 degress rotate. So I read up on c++, examined the other functions in the .cpp file that define the functions, wher I reverse engineered and hacked my way to a boolean function to define the 4th bit, which if I read everything today and understood it, it means in the register 0x22 or 0b0010 0010 we change the 4th bit 0b001[0] 0010 to one, to read 0b001[0] 0010. To accomplish this I wrote

void Adafruit_RA8875::textRotate(boolean on)
{
if (on)
writeReg(0x22, (1 << 4));
else
writeReg(0x22, 0);

}

     in the .cpp file just below enlarge in the text definitions section. What this means is to first define a function named textRotate, so when we use the arduino IDE we can just say tft.textRotate(some value here);. Then the (boolean on) means the value to input is either true or false, the next bit (tiny joke) is on what happens if we change it. As written the function says if true then write to register 0x22, bit 4 a value of 1, otherwise just write 0 instead, end function. The (1 << 4) means that change the 4th bit to 1, just as we needed as stated in the datasheet to rotate the text. Next we need to include the function in the header file, so under text functions we add the line

void textRotate(boolean on);

and thats it. Now when we are programing inside the IDE we can call the function by textRotate(true); to change the orientation of the text, cool huh?

    I also experimented with the display to get to know its capabilities and parameters. First thing is the Max values for both x and y are one pixel less the the actual count of the display. With the grid layout as see here

    So lets say you wanted to draw a rectangle for half the screen, write tft.fillRect(0, 0, 240, 271, RA8875_RED), this will fill the screen half way horizontally. The parameters are (X0, Y0, +X, +Y, color) or (X0, Y0, W, H, color), the starting pixel is always top left, and for rectangles you say how much to add in pixels to form next corner, then it fills the enclosed space with the color specified, which the colors defined are found in the header file under // Colors (RGB565), which you can just insert as stated above. To draw lines use the same syntax as above except tft.drawLine(X(start point), Y(start point), X(end point), Y(end point), RA8875_RED);. So if the statement tft.drawLine(0, 0, 479, 271, RA8875_RED); this would draw a red line from the top left to the bottom right. You'll see that in the Prototype sketch there is some experimenting with text and some lines, which will turn into a number pad, that when a touch is registered in that space, that corresponding number will be written to a buffer in line with the corresponding AT command for the desired function, at which time a touch on the screen will initiate the and transfer the buffer and, fingers crossed, will send the command to the GPRS shield and register the correct desire.

Discussions