olikraus / u8glib

Arduino Monochrom Graphics Library for LCDs and OLEDs
https://github.com/olikraus/u8glib/wiki
Other
1.25k stars 315 forks source link

bitlash #63

Open olikraus opened 9 years ago

olikraus commented 9 years ago

Originally reported on Google Code with ID 63

Add binding to http://bitlash.net/
probably needs something like
u8g line 1 2 3 4
ug8 text x y "text"
--> not sure if bitslash supports strings for user defined functions

Reported by olikraus on 2012-04-16 11:11:42

olikraus commented 9 years ago
Bitlash user defined functions are able to accept string constant arguments.  In your
user function, cast the result of getarg(n) to char* and off you go.  So ug8_text(22,33,"foo")
would work just fine for text placement.

Reported by bill.roy@palmeta.com on 2012-04-19 13:48:28

olikraus commented 9 years ago
Hi Bill
Thanks for clarification!

Reported by olikraus on 2012-04-19 14:44:54

olikraus commented 9 years ago
If you like, it is pretty easy to get printf-formatted output using the built-in bitlash
printf() formatter via the func_printf_handler hook, something like this:

//////////
//
//  Send one byte of generated output to the text display system
//  Used in func_xyprintf() below.
//
void display_put_char(byte) {
    // call your function to display one byte of generated output
    // do bookkeeping for the position of the next char here too
    ...
}

//////////
//
// xyprintf(): print formatted output at [x,y]
//
//  Examples: 
//      xyprintf(0, 0, "Hello, world!");
//      xyprintf(22, 5, "Time: %5d", millis);
//
numvar func_xyprintf(void) {

    // call your function to save the text rendering position
    // set_xy(getarg(0), getarg(1));
    ...

    // generate formatted output
    setOutputHandler(&display_put_char);    // redirect output to handler above
    func_printf_handler(3,4);       // format=arg(3), optional args start at 4
    resetOutputHandler();           // restore normal serial output
    return 0;
}

Reported by bill.roy@palmeta.com on 2012-04-19 15:25:41

olikraus commented 9 years ago
wow, but i guess i have to implement some basic functionailty first.

Reported by olikraus on 2012-04-19 15:46:18

olikraus commented 9 years ago
i never found time to implement this :-(
Closing this for now...

Reported by olikraus on 2014-01-22 19:57:47