PiStorms V2, EV3DEV, graphics programming
 Software and Programming Related   Started by jlbachiochi   2017-04-21 21:06:36 -04:00   Comments: 4    Viewed: 424

  1. jlbachiochi
    jlbachiochi Member
    I'm running a PiStormsV2 with EV3DEV on RPi1, Model B+
    I want to do some simple graphics programming in C++, draw lines, rectangles etc.
    I have installed SDL (v1.2 I think)
    This test program
    #include "SDL.h"
    int main( int argc, char* args[] )
    SDL_Surface* screen = NULL;

    //Start SDL

    const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo ();

    int systemX = videoInfo->current_w ;
    int systemY = videoInfo->current_h ;
    Uint8 bpp = videoInfo->vfmt->BitsPerPixel ;

    printf("%i n", systemX);
    printf("%i n", systemY);
    printf("%i n", bpp);

    //Set up screen
    screen = SDL_SetVideoMode( systemX, systemY, bpp, SDL_SWSURFACE );
    if (!screen)
    printf("SDL_SetVideoMode failedn");
    return 0;

    SDL_Rect r = {0,0,160,120};
    printf("Should see rectangle after 2 secondsn");
    SDL_FillRect(screen,&r, SDL_MapRGB(screen->format, 255,0,0) );

    //Update Screen
    SDL_Flip( screen );

    SDL_Delay(4000 );

    //Quit SDL

    return 0;

    compiles and runs with no errors, but it only displays the three first printf values on the screen.
    I'm hoping to see a red rectangle, but the screen doesn't change at all and after the 9 or so seconds the program simply terminates and returns me to the BrickMan menu.
    The SDL_SetVideoMode does not return an error, but it does appear to do something becuase the last printf statement does not display on the screen at all.

    Any thoughts on how I can instruct the PiStorms screen to go into graphics mode?
    Alternatively, is there another graphics library that I could use to program in C++ to draw on the PiStorms screen.
    jlbachiochi, 2017-04-21 21:06:36 -04:00
  2. setht
    setht Member Staff Member
    Good morning!

    I am not familiar with SDL. We use the Adafruit GFX library in our first-party libraries. We then use the derived class Adafruit_ILI9341. The PiStorms library is written in Python, but the EVs_UIModule is written in C++ and might be more similar to what you are looking for. Let us know if you need more direction!

    Seth Tenembaum
    setht, 2017-04-24 09:21:45 -04:00
  3. jlbachiochi
    jlbachiochi Member
    Thank you Seth.

    That's very useful and looks promising.  I'll start exploring the Adafruit library.

    jlbachiochi, 2017-04-24 15:34:44 -04:00
  4. jlbachiochi
    jlbachiochi Member
    I oened an issue on EV3DEV Github with a similar query and was informed that the GRX library is supported.  I managed to get it working.
    Take a look here https://github.com/ev3dev/ev3dev/issues/872 if anyone is interested.
    jlbachiochi, 2017-04-26 03:03:35 -04:00
  5. (You must log in or sign up to post here)

Log in | Sign up
Tems & Conditions!