Show Posts
Pages: 1 ... 14 15 [16] 17 18 ... 252
226  Using Arduino / Project Guidance / Re: Displaying variable on TFT on: August 17, 2014, 06:18:08 pm
Use int instead of char fro storing the value from analogRead().

Also when your using arrays and a function that is looking for a string, you need to use pointers.

Try drawChar instead of drawString, like Tft.drawChar(str[0],0,160,1,CYAN);
227  Using Arduino / Programming Questions / Re: TFT TouchScreen V1.0 seeedstudio !!!HELP ME!!! on: August 16, 2014, 07:48:01 pm
Yea I know, what I highlighted in my last reply is the line in the code you need to change.

Actually, there is another line that also says Main menu, it might be the one you need to change.

Quote
// create the various menus setting the items, font size, spacing, padding, justification and titles
TouchScreenMenu paddingSubMenu = TouchScreenMenu(paddingSubMenuItems, 2, 5, 20, CENTERJ, "Padding");
TouchScreenMenu spacingSubMenu = TouchScreenMenu(spacingSubMenuItems, 2, 40, 5, CENTERJ, "Spacing");
TouchScreenMenu smallSubMenu = TouchScreenMenu(smallSubMenuItems, 1, 10, 5, CENTERJ, "Small Font");
TouchScreenMenu rightSubMenu = TouchScreenMenu(rightSubMenuItems, 2, 10, 5, RIGHTJ, "Right Justify");
TouchScreenMenu leftSubMenu = TouchScreenMenu(leftSubMenuItems, 2, 10, 5, LEFTJ, "Left Justify");
TouchScreenMenu subMenu = TouchScreenMenu(subMenuItems, 2, 10, 5, CENTERJ, "Sub Menu");
TouchScreenMenu mainMenu = TouchScreenMenu(mainMenuItems, 2, 10, 10, CENTERJ, "Main Menu");
228  Development / Other Software Development / Re: New peek function for HardwareSerial on: August 16, 2014, 05:12:36 pm
@robtillaart
I just downloaded version 1.5.7, and I guess the permissions were changed back, because your code doesn't work anymore.

Edit:
I downloaded 1.5.6 r2 and it doesn't work either, I got the exact same error message :/

Error message:
Quote
Arduino: 1.5.7 (Windows 8 ), Board: "Arduino Uno"

In file included from C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/Arduino.h:221:0,
                 from sketch_aug16a.ino:1:
C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/HardwareSerial.h: In function 'void loop()':
C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/HardwareSerial.h:101:51: error: 'unsigned char HardwareSerial::_rx_buffer [64]' is protected
     unsigned char _rx_buffer[SERIAL_RX_BUFFER_SIZE];
                                                   ^
sketch_aug16a.ino:9:18: error: within this context
In file included from C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/Arduino.h:221:0,
                 from sketch_aug16a.ino:1:
C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/HardwareSerial.h:93:32: error: 'volatile rx_buffer_index_t HardwareSerial::_rx_buffer_head' is protected
     volatile rx_buffer_index_t _rx_buffer_head;
                                ^
sketch_aug16a.ino:11:18: error: within this context
In file included from C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/Arduino.h:221:0,
                 from sketch_aug16a.ino:1:
C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/HardwareSerial.h:94:32: error: 'volatile rx_buffer_index_t HardwareSerial::_rx_buffer_tail' is protected
     volatile rx_buffer_index_t _rx_buffer_tail;
                                ^
sketch_aug16a.ino:13:18: error: within this context

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
229  Development / Other Software Development / Re: New peek function for HardwareSerial on: August 16, 2014, 04:20:52 pm
Well if you think about, all we need to do is access the buffer. The only problem that I can't seem to figure out is how to access the buffer

From HardwareSerial.cpp file.
Quote
struct ring_buffer
{
  unsigned char buffer[SERIAL_BUFFER_SIZE];
  volatile unsigned int head;
  volatile unsigned int tail;
};

Is there any way to access this struct outside the library?
230  Using Arduino / Programming Questions / Re: TFT TouchScreen V1.0 seeedstudio !!!HELP ME!!! on: August 16, 2014, 04:03:07 pm
You mean this line here?

Quote
#include <TouchScreenMenu.h>
#include <TouchScreen.h>
#include <TFT_old.h>
#include <cstddef.h>

// create the array of items for the first sub menu
TouchScreenMenuItem subMenuItems[] = {
  TouchScreenMenuItem("<- Main Menu"),
  TouchScreenMenuItem("Left Justify"),
  TouchScreenMenuItem("Right Justify"),
  TouchScreenMenuItem("Small Font"),
  TouchScreenMenuItem("Spacing"),
  TouchScreenMenuItem("Padding"),
  TouchScreenMenuItem("ENDOFMENU")
};
231  Development / Other Software Development / New peek function for HardwareSerial on: August 16, 2014, 03:55:26 pm
I was trying to help out a new user with his project, but the solution I though would work turned out to only work once.

Users post
The user wanted to send a string from his phone to control a RGB led(s), and the code I gave him was:

Code:
char * strings[3] = {
  "RED", "GREEN", "BLUE"};
byte i = 0;

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  if(Serial.available())
  {
    while(i < 3)
    {
      if(Serial.find(strings[i]))
      {
        Serial.print("Found ");
        Serial.println(strings[i]);
        i = 0;
        break;
      }
      Serial.println(i);
      i++;
    }
    if( i >= 3)
    {
      Serial.println("not found");
      i = 0;
    }
  }
}

This code should check the buffer and see if a string is found, and if not increment the index and check again.

It will find RED if typed in because it is in the first index of the strings array, but it won't find anything else. Upon further investigation, I found out that read() pops the ints (look at the .h and .cpp files for HWS) out of the buffer when it is called so this prevents my code from working. However another function peek() only looks at the first index of the buffer and doesn't move unless read is called.

I would like to add a new peek() function that allows the user to look through the buffer freely without popping anything out, thus allowing my code to work.

I have made an equivalent code that does what I want using the normal HWS library, but it is not very elegant. I'm sure I am not the only person this new function would help, so I am asking if it can be added.

New peek function, simple right?
Code:
int HardwareSerial::peek(uint8_t position)
{
  if (_rx_buffer->head == _rx_buffer->tail) {
    return -1;
  } else {
    return _rx_buffer->buffer[position];
  }
}
232  Using Arduino / Programming Questions / Re: TFT TouchScreen V1.0 seeedstudio !!!HELP ME!!! on: August 16, 2014, 03:15:54 pm
Oh, I put in the wrong file in, sorry.  smiley-lol

Try this one. Same sketches and unpacking procedure.
233  Using Arduino / Project Guidance / Re: 12 Button Keypad Minimal Matrix on: August 16, 2014, 02:50:05 pm
You don't have to use those exact resistor values, but it does take only 2 different values.

example:
1000 and 4700

You can play around with the resistors to give you a better range if needed.
234  Using Arduino / Project Guidance / Re: 12 Button Keypad Minimal Matrix on: August 16, 2014, 01:21:10 pm
True it's not pretty but it works good. If the picture is too big, I am sorry.
235  Using Arduino / Project Guidance / Re: 12 Button Keypad Minimal Matrix on: August 16, 2014, 01:13:35 pm
I made a library for this very problem. Check it out.
Pay close attention as to how the keypad is wired, and the resistor configuration.

OneWireKeypad
236  Using Arduino / Programming Questions / Re: TFT TouchScreen V1.0 seeedstudio !!!HELP ME!!! on: August 16, 2014, 10:22:01 am
You should have a folder called "libraries" located in your arduino sketch folder.
237  Using Arduino / Programming Questions / Re: sending a word on: August 15, 2014, 11:05:41 am
edit:

The code didn't work at all.
238  Using Arduino / Project Guidance / Re: Controlling LED arrays - Not sure where to start on: August 15, 2014, 10:39:53 am
Take a look at this link.
https://learn.adafruit.com/rgb-led-strips/usage
239  Using Arduino / Programming Questions / Re: Pass const char [4][20] PROGMEM into function on: August 14, 2014, 09:53:06 pm
If you have the full code, please post it. Also what do you expect to be on the screen, can you provide an example?
240  Using Arduino / Project Guidance / Re: two-wheeled differential-drive robot rotation (one or two wheels) on: August 14, 2014, 01:46:27 pm
It's basically skid steering, which can be written and controlled easily. What do you plan on controlling it with?

Edit:
Quote
i'd like to use the robot to track a curve aided by a camera located at the ceiling of my room.
This might be a little more difficult and require more hardware and smarter software.
Pages: 1 ... 14 15 [16] 17 18 ... 252