Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Unfortunately not, as the CE does not have the I/O port that is used to make this work. If you can find out a way to use the USB port on the CE though, you might be able to get it to work.
In the same vane as deuteriumoxide's previous post, can someone help me with the Arduino code to send a simple integer (0 to 1023 from an analog read) to my TI-83?
Specifically, how do I format the header and body of the onSendAsCBL2 routine to send a single integer (value 0-1023) when I issue a get( command by my TI-83+?
jam lam wrote:
Specifically, how do I format the header and body of the onSendAsCBL2 routine to send a single integer (value 0-1023) when I issue a get( command by my TI-83+?
Oh man, so sorry that it took this long to get an answer to you! You would want something like this.


Code:

#include "CBL2.h"
#include "TIVar.h"

#define MAXDATALEN 255

uint8_t header[16];
uint8_t data[MAXDATALEN];

CBL2 cbl;
const int lineRed = DEFAULT_TIP;
const int lineWhite = DEFAULT_RING;

// Forward declaration of onRequest() and onReceived() functions
int onReceived(uint8_t type, enum Endpoint model, int datalen);
int onRequest(uint8_t type, enum Endpoint model, int* headerlen,
              int* datalen, data_callback* data_callback);

void setup() {
    Serial.begin(9600);
    cbl.setLines(lineRed, lineWhite);
    cbl.resetLines();
    //cbl.setVerbosity(true, &Serial);      // Comment this in for message information
    cbl.setupCallbacks(header, data, MAXDATALEN, onReceived, onRequest);
}

void loop() {
    cbl.eventLoopTick();
}

int onReceived(uint8_t type, enum Endpoint model, int datalen) {
    // do nothing
    return 0;
}

int onRequest(uint8_t type, enum Endpoint model, int* headerlen,
              int* datalen, data_callback* data_callback)
{
    if (type != VarTypes82::VarReal) {
        Serial.println("Received request for invalid data type");
        return -1; // Can only return a real
    }

    int val = analogRead(0);
    *datalen = TIVar::longToReal8x((long long int)val, data, model);

    memset(header, 0, sizeof(header));
    TIVar::intToSizeWord(*datalen, header);
    header[2] = VarTypes82::VarReal; // Variable type
    header[3] = 'A'; // variable A
    header[4] = 0x00; // pointless zero termination
    *headerlen = 13;

    return 0;
}


In fact, you sufficiently inspired me that I just created a new ReadAnalogSingle example showing exactly this.
So, Tuesday night I spent more hours than I was planning to get to the end of a number of issues and pull requests that were pending on ArTICL, succeeding in doing the following:
  • PR #14: Finally, after a two-year delay, accepted this PR from GitHub user ajcord. I held off in order to test it (and did indeed find some problems, which I later fixed in PR #17 and other commits). It adds a new example, Hello World, which demonstrates how to transfer strings to and from the calculators.
  • Patched Interpretation of Variable Headers: The CBL protocol is shockingly inconsistent, especially about how variable headers are formatted. A set of functions has been added to try to standardize headers somewhat, simplifying what sketch writers need to do to interact with ArTICL.
  • Closed PR #9: geekboy1011 had an even longer-suffering PR, from October 2015, adding the Whack-a-Mole sketch. Since the sketch had already been added, I incorporated changes I had suggested in that discussion and closed it without merging it.
  • Closed several issues: Closed as resolved, stale, or wontfix issues #8, #11, and #12.
  • Added ReadAnalogSingle example: See previous post.

Let me know if you run into any issues or have questions!
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 5 of 5
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement