• I want to extend the Graphics class and be able to use the same "method" names, but extend them. I'd like to do this by creating my own Graphics2 class that inherits from Graphics.

    Problem: How do I create a new Object derived from Graphics2 that's connected to the hardware display, like the built-in LCD object?

    This is the code I found in the source that I'm pretty sure is setting up the LCD var:

    void jswrap_graphics_init() {
    [#ifdef](http://forum.espruino.com/searc­h/?q=%23ifdef) USE_LCD_FSMC
      JsVar *parent = jspNewObject("LCD", "Graphics");
      if (parent) {
        JsVar *parentObj = jsvSkipName(parent);
        JsGraphics gfx;
        graphicsStructInit(&gfx);
        gfx.data.type = JSGRAPHICSTYPE_FSMC;
        gfx.graphicsVar = parentObj;
        gfx.data.width = 320;
        gfx.data.height = 240;
        gfx.data.bpp = 16;
        lcdInit_FSMC(&gfx);
        lcdSetCallbacks_FSMC(&gfx);
        graphicsSplash(&gfx);
        graphicsSetVar(&gfx);
        jsvUnLock2(parentObj, parent);
      }
    [#endif](http://forum.espruino.com/searc­h/?q=%23endif)
    }
    

    Pretty straightforward -- if I was coding in C!

    Is there a way to accomplish the same thing in the Javascript interpreter with standard Espruino interfaces/classes, that would be great!

About

Avatar for dwallersv @dwallersv started