Академический Документы
Профессиональный Документы
Культура Документы
1/68
July 2, 2013
Annikken Andee
Table of Contents
1 What is Annikken Andee?......................................................................................... 5 2 Getting Started...........................................................................................................7
2.1 Hardware Setup........................................................................................................... 7 2.1.1 Connecting Arduino with Computer.................................................................... 7 2.1.2 Annikken Andee Setup......................................................................................... 7 2.2 Bluetooth Pairing........................................................................................................ 8 2.2.1 Annikken Andee and Android Device.................................................................. 8 2.3 Software Setup............................................................................................................ 8
3 Hardware Overview.................................................................................................10
3.1 Power Connections.................................................................................................... 10 3.2 SPI Connections........................................................................................................ 10 3.3 SD Card..................................................................................................................... 10 3.4 LEDs......................................................................................................................... 11
2/68
July 2, 2013
Annikken Andee
4.10.1 Reading A Line From SD................................................................................. 46 4.10.2 Read A Number Of Bytes From SD................................................................. 48 4.10.3 Writing Data to SD........................................................................................... 50 4.11 Sending SMS and Creating Notifications................................................................ 51
5 String Limits............................................................................................................ 53 6 Connector SV2 Functionality.................................................................................. 54 7 Upgrading Firmware................................................................................................54 8 Annikken Andee Specifications...............................................................................57
8.1 Data Rate................................................................................................................... 57 8.2 Dimensions................................................................................................................ 58
3/68
July 2, 2013
Annikken Andee
Version Changes F2 F3 F4 Separated API reference to another document. -added function description of SV2 of Annikken Andee Major change of memory management.
4/68
July 2, 2013
Annikken Andee
Annikken Andee is a Bluetooth add-on shield for the popular Arduino platform. With Annikken Andee's library and its Android app, you can easily create touch interfaces, display data and use phone functions, like SMS on Android platforms without writing any Android code. From your Arduino code, just call a simple function and watch your data simply appearing on your android device! Annikken Andee is your handy mailman in sending and receiving data to and from a mobile device. Piasim Corporation Pte Ltd
Revision F5
Annikken Andee
Annikken Andee is also capable creating displays with touch capabilities, capturing user touch events and sending it to Arduino, where you can code a function to handle the Android touch event in Arduino code. Annikken Andee is also capable of creating displays which allows Android users to key in passwords, text, numbers using the Android keyboard. This information will, likewise, be sent to your Arduino, where you can handle the input. Furthermore, Annikken Andee is designed to take up minimal amount of memory on Arduino. Using the Andee library will take up about (330 + 2n) bytes of memory, where n is the number of displays you wish to create on Annikken Andee. Annikken Andee stores information about what to display in its own memory, and not your Arduino's memory, so as to free up precious Arduino memory for your design. Annikken Andee holds in its memory the data to display on the connected Android device. Your work only involves configuring these memory, i.e. helper.setData(Hello
World), or giving Annikken Andee instructions, i.e. helper.update(), in your Arduino
code. Annikken Andee takes care of the complicated bluetooth wireless management stuff for you. The Andee Library for Arduino abstracts complicated SPI communications between Arduino and Annikken Andee. You only worry about your Arduino design. If you have an existing application with Arduino and wish create an interface on Android, Annikken Andee clearly is THE choice!
6/68
July 2, 2013
Annikken Andee
2 Getting Started
2.1 Hardware Setup 2.1.1 Connecting Arduino with Computer
You should make sure your Arduino board is functioning properly first. Connect Arduino to your computer using USB, note the COM number being assigned by your computer. For mac users, you will be assigned a /dev/tty* instead. Next, launch the Arduino IDE and connect to it using the assigned com port number. You should now load some Arduino examples. For detailed instructions on setting up your Arduino, visit www.arduino.cc to look for setup instructions of your Arduino board.
2.1.2
NOTE! Remove power to Arduino first before plugging in Annikken Andee. Plug Annikken Andee on top of Arduino as shown. Connection is made between the two via the ICSP connector (Arduino) and pin 8. Annikken Andee is powered via the 5V pin of Arduino's ICSP connector.
7/68
July 2, 2013
Annikken Andee
Illustration 5: Blinking LD2 Power up Arduino either by USB (recommended) or power adapter. Led LD2 of Annikken Andee should be blinking, indicating its ready for connection. USB is recommended because it can debug and program Arduino.
Annikken Andee pairs with Android devices without requiring any pin code. From your Android device: Settings -> Bluetooth -> Scan
Click on the Annikken Andee device that shows up after scanning to pair with it. Should your device request for a pin code, key in 0000.
8/68
July 2, 2013
Annikken Andee
Connect Button
Select the Annikken Andee device you with to connect with. Annikken Andee's LD2 should be blinking red, indicating an active connection.
Install Annikken Andee Library and run the examples. The library can be downloaded from www.annikken.com/annikkenandee/AndeeLibrary.zip. Detailed instructions are in section 4.1 Installing Andee Library. You should see data appearing in the app by running the example sketches provided under Examples -> Andee of Arduino IDE (Arduino code are called sketches).
9/68
July 2, 2013
Annikken Andee
3 Hardware Overview
3.1 Power Connections
Annikken Andee draws a 5V supply from Arduino. Internal circuitry onboard then steps down this to 3.3V to power all of Annikken Andee. Power connection is made via the ICSP connector of Arduino.
3.3 SD Card
The SD Card slots accepts standard sd cards. It allows users to have an extra memory storage should they need it. The read write functions are provided in the Andee library Piasim Corporation Pte Ltd
Revision F5
10/68
July 2, 2013
Annikken Andee
for Arduino.
3.4 LEDs
There are 3 leds. ON: Indicates that power is being supplied to Annikken Andee LD1:
Blinking Green Indication presence of write activity to Annikken Andee. LD2: Blinking Green No bluetooth connection with Android
LD1 and LD2: Both blinking red SDCard not present or image.hex file not found. (Bootload mode)
11/68
July 2, 2013
Annikken Andee
Alternate Green (LD1) and Red (LD2) Firmware programming in progress. (Bootload mode)
12/68
July 2, 2013
Annikken Andee
13/68
July 2, 2013
Annikken Andee
Illustration 9: Libraries folder created by Arduino 3. Here create a directory named Libraries if it does not exists. Normally this library will be create when you install Arduino and ran it. 4. Unzipped the downloaded file AndeeLibrary.zip, and copy the entire Andee folder into the Libraries folder. Note that your Libraries folder may contain other libraries contributed by other Arduino users.
Illustration 10: Copy Andee Folder into Libraries 5. Launch the Arduino IDE. Go to Sketch -> Import Library. You should see the Andee library listed. Note: You may need to restart Arduino IDE to see the library listed. You can now use the Annikken Andee library for your Arduino projects.
14/68
July 2, 2013
Annikken Andee
15/68
July 2, 2013
Annikken Andee
From Arduino, open up the example Demo1_HelloWorld. From Arduino, select File->Examples ->Andee -> Demo1_HelloWorld On Android, turn on bluetooth, pair your Android with your Annikken Andee. Annikken Andee should have a name like Andee XXXX, where XXXX are numbers. On Android, launch Annikken Andee App (available from Google Play store). Click on Bluetooth List if its available to you. Choose the appropriate Annikken Andee by checking
its box and click the 'Connect' button at the bottom of Illustration 12: Bluetooth the list. Once connected, you should notice that LD2 List of devices of Annikken Andee is blinking red. Upload your program by clicking the 'Upload' button from your Arduino IDE. Your program should compile and once loaded you should see a screen like this on your Android device. If data is not showing, please reset Arduino.
Illustration 13: Demo1_HelloWorld Screenshot Congratulations! Your Android is now communicating with Annikken Andee.
16/68
July 2, 2013
Annikken Andee
Illustration 14: Basic Program Flow We will use Demo1_HelloWorld demo program included with the Andee library to show you where to perform these tasks in an Arduino sketch.
17/68
July 2, 2013
Annikken Andee
//Program outputs Hello World to a display #include <SPI.h> #include <Andee.h> #include <time.h> //to use delay function
//Declare an instance of AndeeHelper to help manage our display. AndeeHelper andeeHelper; void setup(){ //Setup communications between Annikken Andee and Arduino Andee.begin(); andeeHelper.setId(14); //Give this helper a unique ID andeeHelper.setType(DATA_OUT); //Set Type to DATA_OUT andeeHelper.setLocation(0, 0, FULL); //Row, Order, Span //Set the title, data and units fields of our display. AndeeHelper.setTitle("Hello Title"); AndeeHelper.setData("This is Data Field"); andeeHelper.setUnit("Units Field"); } Andee.clear();//Clear the screen of any previous displays
void loop(){ // Tell Andee to display our DATA_OUT andeeHelper.update(); //Delay for 1 second, here we send update every second. delay(1000); }
To use Andee in Arduino sketches, we need to include the necessary libraries. Since our Andee.h library uses the SPI.h library, be sure to include it in your sketch.
Create Helpers Tasks refer to flowchart of previous section. We need to use AndeeHelper class to help manage our display on Android. You should have a AndeeHelper instance for each display on Android. This this example, we only want one DATA_OUT display. So we declare just one andeeHelper object. Next we will declare a AndeeHelper variable.
18/68
July 2, 2013
Annikken Andee
We use this instance to save data, like title and location or the text to display on Android, in Annikken Andee's memory via various function calls. Every Arduino sketch/program needs to have: void setup(){ } void loop() {}
The Arduino's setup() function is only called once during the execution of the Arduino program. Normally, we do some setup here. It is here we do things that needs to be done first, or things that need to be done only once.
#include <SPI.h> #include <Andee.h> AndeeHelper andeeHelper; void setup(){ Andee.begin(); andeeHelper.setId(14); andeeHelper.setType(DATA_OUT); andeeHelper.setLocation(0,0,FULL);
Andee.begin() We call Andee.begin() to setup communications between Annikken Andee and the Arduino board.
void setId(int id) When you call setId(id), you are associating this andeeHelper with a MemBlock inside Annikken Andee. Annikken Andee will initialize MemBlock[id] with defaults upon receiving this command.
19/68
July 2, 2013
Annikken Andee
Illustration 15: Memory Management in Annikken Andee After you have associated the andeeHelper with a MemBlock in Annikken Andee, any functions you call with andeeHelper will be directed at the MemBlock[id]. In our example we are using MemBlock[14], setId(14). void setType(char type) Use the pre-defined macros, DATA_OUT: data display, BUTTON_IN: button display, KEYBOARD_IN: display which allow user to send characters typed by Android keyboard to Arduino. This our example, we set to DATA_OUT as we want to simply display something. void setLocation(int row, int order, int span) This function, we give our helper location information for our display. For row, give it an integer from 0 to 3, corresponding to row 1 to row 4 of android display. For order, we set it to zero first. Order dictates the order (left-to-right) in which displays on the same row appears. A bigger order will be place on the right hand side of a smaller order. Order 1 Order 2 Order 3
20/68
July 2, 2013
Annikken Andee
By setting it to zero, we are leaving it for the program to decide. Displays that are called to be output first will appear on the leftmost. For span, we want this display to fill the width of Android screen, so we use the macro FULL. Other macros you can use are: ONE_THIRD TWO_THIRD ONE_QUART THREE_QUART HALF Fills one third of width Fills two third of width Fills one quarter of width Fills three quarters of width Fills half the width
Next, we give information to our helper that tells it what to populate our display with. Data displays have three fields we can use: title, data and unit. They can be used with the following functions.
setTitle(char*)
setData(char*) setUnit(char*)
21/68
July 2, 2013
Annikken Andee
void setTitle(char* title) void setData(char* data) void setUnit(char* unit)
Use the the above function to provide title, data and unit information to our DATA_OUT display. You can also use override functions to set title, data or unit. Character strings are limited to a maximum of 64 bytes.
void setTitle(char*) void setTitle(int value) void setTitle(float value, int numberOfDecimalPlaces) void setTitle(double value, int numberOfDecimalPlaces) void setData(char*) void setData(int value) void setData(float value, int numberOfDecimalPlaces) void setData(double value, int numberOfDecimalPlaces) void setUnit(char*) void setUnit(int value) void setUnit(float value, int numberOfDecimalPlaces) void setUnit(double value, int numberOfDecimalPlaces)
void clear() We call this to clear the Android screen of all previous displays. Note that by calling this, Annikken Andee's MemBlocks are not erased. The previous fields you saved in Annikken Andee's MemBlocks are intact. Update Helper With Data Task We move on to create the Arduino's loop() function. This Arduino program will keep calling its loop() function when its running. Normally, we perform data acquisitions or updates in the loop() function. You can think of this as the program's main loop. For this example, we do not have any data to update. Let's move on to the next task. Piasim Corporation Pte Ltd
Revision F5
22/68
July 2, 2013
Annikken Andee
#include <SPI.h> #include <Andee.h> AndeeHelper andeeHelper; void setup(){ ... } void loop(){ }
Up till now, if you compile and upload the Arduino sketch, you will not see anything appear on your Android screen. This is because all we have done up till this point was only to give information to our Annikken Andee. You have not instructed Annikken Andee to create any display yet. Update Android Screen Task void update() Let's tell our helper to inform Android about our display.
#include <SPI.h> #include <Andee.h> AndeeHelper andeeHelper; void setup(){ ... } void loop(){ andeeHelper.update(); Delay(1000); //Delay 1 second before the next update. }
When this function is called, Annikken Andee will inform Android where and what to display based on the information we gave it in our setup loop. Now we can upload this program to our Arduino board. You should see the display appearing on your Android screen.
23/68
July 2, 2013
Annikken Andee
Illustration 17: Snapshot of Demo2_SendAnalogReadings Notice that we create a function called setInitialData() helper functions to configure the MemBlocks of Annikken Andee. Let's bring the attention to the loop() of Arduino. Instead of using setData(...) and update() in sequence, we tell Annikken Andee to display data using updateData(...) function. Calling this will instruct Annikken Andee to update Android using the data we pass in. It has the effect of setData(...) and update() together, but it is less heavy in Piasim Corporation Pte Ltd
Revision F5
24/68
July 2, 2013
Annikken Andee
the sense that only a single instruction is sent from Arduino to Annikken Andee.
void updateData(char*) void updateData(int value) void updateData(float value, int numberOfDecimalPlaces) void updateData(double value, int numberOfDecimalPlaces)
You should see the above screen after you upload the sketch to Arduino. Everything in blue can be confusing, you may want to bring attention to a certain analog pin, let's say A1 of Arduino, to show red. You can do so using the setColor(char*
argb) and setTitleColor(char* argb) function. Let's add this function call inside
Compile and upload the program and you should see the following screen. Piasim Corporation Pte Ltd
Revision F5
25/68
July 2, 2013
Annikken Andee
Illustration 20: Snapshot of color change for DATA_OUT Let's change some more colors, say for Analog A2. Let's change it to a light gray box with a white title bar.
Illustration 21: Changing more colors Compile and upload to see the change.
Illustration 22: Light colors Seems like we cannot see out text with light backgrounds. In Annikken Andee, you have a choice of white text or black text, i.e. TEXT_LIGHT, TEXT_DARK. Use the Piasim Corporation Pte Ltd
Revision F5
26/68
July 2, 2013
Annikken Andee
following function to set them.
Illustration 24: DATA_OUT white background with black text Illustration 23: Setting the text colors to white or black Here is a list of settable color macros, you can pass in your own 8 character string as well: Macros BLACK LIGHT_BLUE BLUE CYAN DKGRAY GRAY TRANSPARENT ARGB String "FF000000" "FF33B5E5" "FF0099CC" "FF00FFFF" "FF444444" "FF888888" "00FFFFFF" Macros LTGRAY GREEN MAGENTA RED WHITE YELLOW ARGB String "FFCCCCCC" "FF00FF00" "FFFF00FF" "FFFF0000" "FFFFFFFF" "FFFFFF00"
27/68
July 2, 2013
Annikken Andee
Illustration 25: BUTTON_IN and KEYBOARD_IN displays There are two ways to send messages from Android to Arduino through Annikkken Andee. BUTTON_IN displays send touch events to Arduino and KEYBOARD_IN sends a text entered by Android's soft keyboard to Arduino. Demo3_ ButtonAndKeyboard from examples shows you these two inputs.
4.6.1
BUTTON_IN Displays
BUTTON_IN displays sends a message to Annikken Andee when a user touches it. Your Arduino sketch can catch this using the isPressed() function. Below is a code of how to create a button on Android and catch the response.
28/68
July 2, 2013
Annikken Andee
If you touch the BUTTON_IN display on Android, you will notice it will be overlay with a spinner when you touch it, and sometime later it goes away and a tick is shown at the bottom right corner of the BUTTON_IN display. In Annikken Andee App, all buttons and keyboards will show a waiting for ack spinner when user touches them. In the case for KEYBOARD_IN, waiting for ack spinner shows after users sends a text input out. The waiting for ack will disappear and a tick will be shown once the app receives an ack from Annikken Andee. Arduino users must instruct Annikken Andee to send ack using the ack() function. This will allow user to know if Arduino has handled the touch event already or not.
Illustration 28: Feedback box updated after BUTTON is pressed Piasim Corporation Pte Ltd
Revision F5
29/68
July 2, 2013
Annikken Andee
30/68
July 2, 2013
Annikken Andee
Illustration 30: Options shown after long press on "waiting for ack" button In the event when and ack is not received after sometime, the Android user can choose to resend the touch event (Resend), cancel it (Cancel Click) or continue waiting (Do Nothing). These options are made available via a long press on the BUTTON_IN display.
4.6.2
KEYBOARD_IN Displays
KEYBOARD_IN displays allows an Android user to send a character string (not more than 64 characters) from Android to Arduino. When an Android user touches a KEYBOARD_IN button, the Android app will provide a keyboard for user to key in a message to be sent to Annikken Andee. The way Arduino gets notified is similar to the way BUTTON_IN displays notify, via isPressed() function. Note the similarity of the code. Note that button and keyboard are AndeeHelpers instances, i.e. AndeeHelper Piasim Corporation Pte Ltd
Revision F5
31/68
July 2, 2013
Annikken Andee
button, keyboard;
Illustration 31: Comparing BUTTON_IN and KEYBOARD_IN code Arduino code need to call getKeyboardMessage(char* buffer) to retrieve the user message from Annikken Andee. Note that userKeyboardInput is a char buffer you have to define in Arduino, i.e. userKeyboardInput[32]. Piasim Corporation Pte Ltd
Revision F5
32/68
July 2, 2013
Annikken Andee
Illustration 33: Soft keyboard shown when user presses button Illustration 32: Feedback updated with user keyboard input You can control the keyboard type using Arduino code. i.e. obscuring text or not obscuring text. This is normally used where user is to enter a password but do not wish the entered characters to be shown. Keyboard type is set using
setKeyboardType(char) function. In the example below, we used setKeyboardType(ALPHA_NUMERIC_PW).
33/68
July 2, 2013
Annikken Andee
Illustration 34: Obscured text input There is a total of 8 types of keyboard input you can set. The first four as described are using Android's system soft keyboard, or any other third-party keyboard the user has installed. A _PW appended behind each macros would mean that the entered text will be obscured.
34/68
July 2, 2013
Annikken Andee
Keyboard Type MACRO Description
Screenshot
35/68
July 2, 2013
Annikken Andee
ALPHA_NUMERIC ALPHA_NUMERIC_PW The full set of Android keyboard with numbers and characters.
ANDROID_NUMERIC ANDROID_NUMERIC_PW
(Landscape)
36/68
July 2, 2013
Annikken Andee
Android numeric keyboard in the sense that it shows the button while in landscape mode. For Android numeric keyboard, only the keyboard and text entry field is shown.
(Portrait)
ANDEE_NUMERIC_B ANDEE_NUMERIC_B_PW
(Landscape)
37/68
July 2, 2013
Annikken Andee
(Portrait)
38/68
July 2, 2013
Annikken Andee
39/68
July 2, 2013
Annikken Andee
Let's see the setInitialData() function. Here you should notice that the two displays are updated here instead of inside the Arduino's loop function. This is so not to recreate the displays once remove() has been called. If we call update() on the two displays in the loop(), the displays will reappear after remove() has been called.
40/68
July 2, 2013
Annikken Andee
41/68
July 2, 2013
Annikken Andee
Now for the handleKeyboardMessage() function. First we get the message from Annikken Andee using getKeyboardMessage(char*) function.
Illustration 37: handleKeyboardMessage() Then we call remove() on display[0] or display[1], depending on which what the user entered. The handleKeyboardMessage() is called in Arduino's loop function. Piasim Corporation Pte Ltd
Revision F5
42/68
July 2, 2013
Annikken Andee
43/68
July 2, 2013
Annikken Andee
You should notice that display number 2 is automatically flushed to the left of Android screen. This is the default behavior even when you have set the order of display to 1. Because in the first row, there is no displays before display 2, therefore it appears at the leftmost. If you wish for the display 2 to occupy the same position even after removing display 1, try modifiying display[0] to have transparent title and field color instead of calling remove(). This is demonstrated using the Set Transparent button.
Illustration 41: Creating a transparent display Here is the code for createTransparentUnit(). When pressing the button Set Transparent, you should see the following screen.
44/68
July 2, 2013
Annikken Andee
To illustrate the use of these functions, check out DEMO5_GetConnectedMACID. Annikken Andee keeps track of the unique bluetooth mac id a connected Android device. This mac id can be obtained with the request command GET CONNECTED MAC_ID. You need to open up Arduino's serial port monitor to see the error message when no Android is connected.
45/68
July 2, 2013
Annikken Andee
Illustration 45: Snippet of sendCommand function Here is a table of commands you can use: Command String GET CONNECTED MAC_ID Description Get the unique bluetooth mac id of connected Android append with RSSI data. GET BTADDR GET BT NAME Get the unique bluetooth mac id of Annikken Andee Get Annikken Andee's Bluetooth name SET BT NAME <new name> Set Annikken Andee's Bluetooth name to <new name> No reply to this request. Note that you still need to supply a rcvdBuffer for the function. The replies, often text messages, will be saved into the buffer you supplied. In this case example, cmdReply[64]. If successful, sendCommand() function returns a true, else it returns a false, with the error message copied inside cmdReply, or the buffer you supply into the function. Piasim Corporation Pte Ltd
Revision F5
46/68
July 2, 2013
Annikken Andee
47/68
July 2, 2013
Annikken Andee
Illustration 47: If no Android is connected, Illustration 46: Screenshot of Demo5_GetConnectedMACID serial port shows this
48/68
July 2, 2013
Annikken Andee
Illustration 48: Demo6 Source Code Arduino program will instruct Annikken Andee to display a DISCONNECT button if Andee.isConnected() returns true. And if the button is being touched by a user, Arduino instructs Annikken Andee to disconnect from the Android device by calling
Andee.disconnect(). Once disconnected, you should see the screen as shown below.
49/68
July 2, 2013
Annikken Andee
4.10
for Arduino users. For Arduino coder, you need to complicated yourself with setting up of SPI for the sdcard. Data to be written and sent is also being done via the following API calls from Andee library:
int readLineFromSD(char* filename, int offset, char* replyBuffer, int maxLen, char* delimitString) int readBytesFromSD(char* filename, int offset, char* replyBuffer, int numOfBytesToRead) int appendSD(char* filename, char* contents, char* errorMsgBuffer)
50/68
July 2, 2013
Annikken Andee
Note that filenames should not contain the character ';' and ','. All these functions returns an integer specifying the current file location. If a '-1' is returned, it means an exception has occurred while performing the functions. The detailed error message will be saved in errorMsgBuffer[] - which is a character buffer you have to defined it in Arduino. Demo7_SDFunctions demonstrate the above functions. To run the above demo, you need to have a sdcard. Create a text file, name it as demo7.txt and load it with the contents as shown.
Next upload Demo7_SDFunctions to an Arduino can run it. Connect with an Android device and you should see the following screen.
51/68
July 2, 2013
Annikken Andee
52/68
July 2, 2013
Annikken Andee
Notice for 2nd and 3rd line of display, there are small white right-pointing arrows on the right side of display. This means that there are more displays on the right and can be accessed by dragging your finger across the row from right to left.
4.10.1
53/68
July 2, 2013
Annikken Andee
Illustration 53: Variables defined globally for use in Demo7 Illustration 54: Initialization of button
54/68
July 2, 2013
Annikken Andee
55/68
July 2, 2013
Annikken Andee
Illustration 55: Code segment from loop() The readLineFromSD(...) functions returns an int indicating the current file position. For example if 5 bytes were to be read, the value returned would be 5. Therefore, in this example, if you were to read the next line beginning from where you left off, you would pass in a value of 5 as the offset value. Try pressing the Read Line button once.
Illustration 56: DATA_OUT display showing the read contents and returned file pointer position as variable offset Current file pointer position
File pointer
0 L
1 i
2 n
3 e
4 1
6 t
7 e
8 s
9 t
10 i
11 n
12 g
13 \n
14 L
15 i
Contents
Delimiter not included in returned sd contents Continue pressing the Read Line button will show you the contents of demo7.txt line-by-line delimited by \n. Once end of file is reached, you should see this.
56/68
July 2, 2013
Annikken Andee
Illustration 57: Display showing end of file Remember that a returned value of -1 indicated an exception, and the exception description is placed in your received contents buffer, in this case cmdReply[64].
4.10.2
In Demo7_SDFunctions, there are two buttons to to be used with this function. Set Offset and Set Number Bytes.
Illustration 58: Set Offset and Set Number Bytes Variable offset will shift the file position pointer
File pointer
0 L
1 i
2 n
3 e
4 1
6 t
7 e
8 s
9 t
10 i
11 n
12 g
13 \n
14 L
15 i
Contents
NumOfBytesToRead specifies number of bytes to read from file position Here is the code segment for Set Offset button and Set Number Bytes button.
57/68
July 2, 2013
Annikken Andee
Illustration 59: Code segment for Set Offset and Set Number Bytes button
Illustration 60: What the Read Bytes button do For example, set offset to 1 and numBytesToRead to 5 will show you the following result.
4.10.3
Writing Data to SD
You have two functions to use to write data to sdcard. Piasim Corporation Pte Ltd
Revision F5
58/68
July 2, 2013
Annikken Andee
The appendSD(...) function write contents starting from the end of file specified by filename. The writeSD(...) writes contents starting from file position specified by offset.
Illustration 63: Code segment of appendSD and writeSD For writeSD, the offset is set using the Set Offset button also. The WRITE SD button is hidden on the right side of APPEND SD function. Here is the list of possible errors you may received during any SD read/write functions: Error Message NO SDCARD FILE NOT FOUND OPENING FILE ERROR READ FILE ERROR EOF REACHED UNABLE TO CLOSE FILE Description SD card not insert or not properly inserted. Cannot find the specified file. There was an error opening the file. Error reading file, most probably corrupted. End of file. An error occurred while trying to close the file after reading 59/68
July 2, 2013
Annikken Andee
or writing.
4.11
Android device, to send sms to a recipient or to create a notification. You need to create AndeeHelper instances and set the proper messages as shown.
60/68
July 2, 2013
Annikken Andee
61/68
July 2, 2013
Annikken Andee
62/68
July 2, 2013
Annikken Andee
The Arduino's loop function basically handles the displaying of buttons on Android screen using the update() function and performing the sms.send() and
notice.notify() function.
63/68
July 2, 2013
Annikken Andee
5 String Limits
There is a maximum limit you the fields in Annikken Andee can take. Display Type DATA_OUT Settable Fields Title Data Unit BUTTON_IN KEYBOARD_IN Title Title User Input HintText SD ReadWrite SMS_SENDER NOTIFICATION Read and write contents Recipient Message Title Message Ticker Max Characters (Bytes) 64 64 64 64 64 64 64 64 in one function call 64 64 64 64 64
64/68
July 2, 2013
Annikken Andee
Function Reserved. Reserved. Digital HIGH when LD2 = RED. Digital HIGH when LD2 = GREEN. Reserved. Reserved. Reserved. Reserved.
Users can wire these pins to their external systems for detection purposes. For example, you may need to put Annikken Andee into an enclosure. However, doing that will obscure the LD2 from view. Users may still want to be notified of connection status via the LD2 led. Instead of soldering your own wire to the surface mounted LD2, you can instead use pin 3 and pin 4 of SV2 to connect it to your external LED.
7 Upgrading Firmware
Annikken Andee's firmware can be upgraded using a sdcard. Firmware releases can Piasim Corporation Pte Ltd
Revision F5
65/68
July 2, 2013
Annikken Andee
be obtained from Annikken Andee's website,
www.annikken.com/annikkenandee/AndeeLibrary.zip. The correct firmware to use with a library build is included in the zip file. Copy the <name>.hex file to a SDCARD and rename it to image.hex.
Insert the SDCARD (with firmware file) into Annikken Andee's SDCARD slot. Apply power to Annikken Andee. Annikken Andee's LD2 should be showing a blinking green light. This shows that it is in normal mode.
Put Annikken Andee into bootloading mode with the following steps: Press and hold BTN2 While still holding BTN2, press and release the RESET button.
66/68
July 2, 2013
Annikken Andee
LD1 will flash RED and LD2 will flash GREEN alternately, indicating firmware programming is in progress. You can release BTN2 once you observed this.
Annikken Andee will put itself back to normal mode once firmware programming is done indicated by LD2 blinking green light.
67/68
July 2, 2013
Annikken Andee
Enquiries:
sales@piasim.com
68/68
July 2, 2013