lang:c:gfx_mgl
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| lang:c:gfx_mgl [2017/11/01 09:35] – Brouillon root | lang:c:gfx_mgl [2025/11/12 13:21] (Version actuelle) – Mise à jour avec la v2018-11-26 root | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | L' | + | L' |
| + | L' | ||
| + | ===Documentation=== | ||
| + | [[http:// | ||
| + | |||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | - {{ : | ||
| + | |||
| + | ===Programme de base=== | ||
| + | Sur la base de (5), on a comme application de départ : | ||
| + | <file c main.c> | ||
| + | #include < | ||
| + | |||
| + | bool APP_ObjectMessageCallback(GFX_GOL_TRANSLATED_ACTION action, GFX_GOL_OBJ_HEADER *header, GFX_GOL_MESSAGE *msg) | ||
| + | { | ||
| + | return true; | ||
| + | } | ||
| + | |||
| + | bool APP_ObjectDrawCallback(void) | ||
| + | { | ||
| + | } | ||
| + | |||
| + | void APP_CreateScreens() | ||
| + | { | ||
| + | GFX_ColorSet(WHITE); | ||
| + | GFX_ScreenClear(); | ||
| + | } | ||
| + | |||
| + | void TouchGetMsg(GFX_GOL_MESSAGE *msg) { | ||
| + | } | ||
| + | |||
| + | int main() | ||
| + | { | ||
| + | GFX_GOL_MESSAGE msg; | ||
| + | GFX_Initialize(); | ||
| + | GFX_GOL_MessageCallbackSet(APP_ObjectMessageCallback); | ||
| + | GFX_GOL_DrawCallbackSet(APP_ObjectDrawCallback); | ||
| + | APP_CreateScreens(); | ||
| + | |||
| + | while(1) | ||
| + | { | ||
| + | if (GFX_GOL_ObjectListDraw() == GFX_STATUS_SUCCESS) | ||
| + | { | ||
| + | TouchGetMsg(& | ||
| + | GFX_GOL_ObjectMessage(& | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Pour compiler : | ||
| + | gcc main.c | ||
| + | |||
| + | Il est à noter qu'il faut maintenant définir le fichier '' | ||
| + | |||
| + | <WRAP center round tip 60%> | ||
| + | N' | ||
| + | </ | ||
| + | |||
| + | ===system_config.h=== | ||
| + | <file c system_config.h> | ||
| + | #ifndef system_config_h_ | ||
| + | #define system_config_h_ | ||
| + | |||
| + | #include " | ||
| + | |||
| + | # | ||
| + | </ | ||
| + | |||
| + | ===gfx_config.h=== | ||
| + | La librairie est plutôt bien faite avec des warnings en cas de ''# | ||
| + | |||
| + | Il faut définir : | ||
| + | |||
| + | * ''# | ||
| + | |||
| + | * ''# | ||
| + | Utilisé par la fonction utilisateur '' | ||
| + | |||
| + | <file c gfx_config.h> | ||
| + | #ifndef GFX_CONFIG_H_ | ||
| + | #define GFX_CONFIG_H_ | ||
| + | |||
| + | #define GFX_CONFIG_COLOR_DEPTH 24 | ||
| + | |||
| + | #define GFX_EXTERNAL_FONT_RASTER_BUFFER_SIZE 100 | ||
| + | |||
| + | // Sinon la couleur WHITE n' | ||
| + | #define GFX_CONFIG_PALETTE_DISABLE | ||
| + | |||
| + | // Parce qu'on n' | ||
| + | #define __prog__ | ||
| + | |||
| + | # | ||
| + | </ | ||
| + | |||
| + | ===Ajouter les fonctions manquantes=== | ||
| + | / | ||
| + | main.c: | ||
| + | main.c: | ||
| + | / | ||
| + | main.c: | ||
| + | main.c: | ||
| + | main.c: | ||
| + | main.c: | ||
| + | main.c: | ||
| + | main.c: | ||
| + | collect2: error: ld a retourné le statut de sortie 1 | ||
| + | |||
| + | gcc main.c -Iframework -I. framework/ | ||
| + | |||
| + | Il manque encore dans '' | ||
| + | <code c> | ||
| + | #define DISP_HOR_RESOLUTION XXX | ||
| + | #define DISP_VER_RESOLUTION XXX | ||
| + | </ | ||
| + | |||
| + | Et le message d' | ||
| + | framework/ | ||
| + | <code c># | ||
| + | |||
| + | gcc main.c -Iframework -I. framework/ | ||
| + | |||
| + | Il manque encore | ||
| + | <code c> | ||
| + | #define GFX_malloc(pObj) malloc(pObj); | ||
| + | #define GFX_free(pObj) free(pObj) | ||
| + | </ | ||
| + | |||
| + | Dans le fichier '' | ||
| + | |||
| + | ===Supprimer les inline=== | ||
| + | Le compilateur de Microchip a l'air d' | ||
| + | |||
| + | Il faut remplacer les '' | ||
| + | sed -i " | ||
| + | |||
| + | ===Ajouter les fonctions manquantes=== | ||
| + | * '' | ||
| + | |||
| + | <code c> | ||
| + | static GFX_COLOR buff[DISP_VER_RESOLUTION][DISP_HOR_RESOLUTION]; | ||
| + | |||
| + | GFX_COLOR GFX_PixelGet(uint16_t x, uint16_t y) | ||
| + | { | ||
| + | if ((x >= DISP_HOR_RESOLUTION) || (y >= DISP_VER_RESOLUTION)) | ||
| + | { | ||
| + | return BLACK; | ||
| + | } | ||
| + | return buff[y][x]; | ||
| + | } | ||
| + | |||
| + | GFX_STATUS GFX_PixelPut(uint16_t x, uint16_t y) | ||
| + | { | ||
| + | if ((x >= DISP_HOR_RESOLUTION) || (y >= DISP_VER_RESOLUTION)) | ||
| + | { | ||
| + | return GFX_STATUS_FAILURE; | ||
| + | } | ||
| + | buff[y][x] = GFX_ColorGet(); | ||
| + | return GFX_STATUS_SUCCESS; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | * '' | ||
| + | <code c> | ||
| + | GFX_STATUS_BIT GFX_RenderStatusGet() | ||
| + | { | ||
| + | return GFX_STATUS_SUCCESS_BIT; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | * '' | ||
| + | <code c> | ||
| + | void DRV_GFX_Initialize() | ||
| + | { | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | * Fonction faussement manquante | ||
| + | |||
| + | / | ||
| + | gfx_gol.c: | ||
| + | / | ||
| + | gfx_primitive.c: | ||
| + | |||
| + | Il faut enlever le '' | ||
| + | |||
| + | * '' | ||
| + | <code c> | ||
| + | GFX_STATUS GFX_ExternalResourceCallback(GFX_RESOURCE_HDR * pResource, uint32_t offset, uint16_t nCount, void * pBuffer) | ||
| + | { | ||
| + | return GFX_STATUS_SUCCESS; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | A ce stade là, tout marche. Une archive complète est mise à disposition en bas de la page. | ||
| + | |||
| + | ====Dessins==== | ||
| + | ===Ajout de quelques dessins=== | ||
| + | <code c> | ||
| + | GFX_ColorSet(WHITE); | ||
| + | GFX_ScreenClear(); | ||
| + | GFX_LineStyleSet(GFX_LINE_STYLE_THICK_SOLID); | ||
| + | GFX_ColorSet(RED); | ||
| + | GFX_LineDraw(0, | ||
| + | GFX_ColorSet(GREEN); | ||
| + | GFX_LineDraw(160, | ||
| + | GFX_ColorSet(BLUE); | ||
| + | GFX_LineDraw(260, | ||
| + | GFX_ColorSet(BLACK); | ||
| + | GFX_LineDraw(160, | ||
| + | </ | ||
| + | |||
| + | Et enregistrement du résultat dans un fichier qui sera converti en image via un programme externe. | ||
| + | |||
| + | <code c> | ||
| + | if (GFX_GOL_ObjectListDraw() == GFX_STATUS_SUCCESS) | ||
| + | { | ||
| + | TouchGetMsg(& | ||
| + | GFX_GOL_ObjectMessage(& | ||
| + | |||
| + | FILE *fp = fopen("/ | ||
| + | (void) fprintf(fp, " | ||
| + | for (int j = 0; j < DISP_VER_RESOLUTION; | ||
| + | { | ||
| + | for (int i = 0; i < DISP_HOR_RESOLUTION; | ||
| + | { | ||
| + | static unsigned char color[3]; | ||
| + | color[0] = (buff[j][i] >> 16) % 256; /* red */ | ||
| + | color[1] = (buff[j][i] >> 8) % 256; /* green */ | ||
| + | color[2] = (buff[j][i] >> 0) % 256; /* blue */ | ||
| + | (void) fwrite(color, | ||
| + | } | ||
| + | } | ||
| + | (void) fclose(fp); | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | gcc -Iframework -I. framework/ | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ===Ajout d'un bouton=== | ||
| + | Il faut ajouter un '' | ||
| + | |||
| + | <code c> | ||
| + | GFX_GOL_OBJ_SCHEME GOLSchemeDefault; | ||
| + | </ | ||
| + | |||
| + | Définir le thème | ||
| + | <code c> | ||
| + | GOLSchemeDefault.TextColor0 = WHITE; | ||
| + | GOLSchemeDefault.Color0 = BLACK; | ||
| + | GOLSchemeDefault.Color1 = GFX_RGBConvert(0x7F, | ||
| + | GOLSchemeDefault.EmbossDkColor = RED; | ||
| + | GOLSchemeDefault.EmbossLtColor = BLUE; | ||
| + | GOLSchemeDefault.EmbossSize = 3; | ||
| + | GOLSchemeDefault.CommonBkColor = BLACK; | ||
| + | GOLSchemeDefault.pFont = NULL; | ||
| + | </ | ||
| + | |||
| + | et le bouton | ||
| + | <code c> | ||
| + | GFX_XCHAR UP_Msg[]={' | ||
| + | |||
| + | if (GFX_GOL_ButtonCreate(11, | ||
| + | { | ||
| + | printf(" | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | gcc -Iframework -I. framework/ | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Il manque le texte mais c'est normal car '' | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | Microchip licenses to you the right to use, modify, copy and distribute | ||
| + | Software only when embedded on a Microchip microcontroller or digital signal | ||
| + | controller that is integrated into your product or third party product | ||
| + | (pursuant to the sublicense terms in the accompanying license agreement). | ||
| + | |||
| + | Donc la librairie n'est utilisable que sur du matériel Microchip. | ||
| + | |||
| + | </ | ||
| + | |||
| + | {{ : | ||
lang/c/gfx_mgl.1509525332.txt.gz · Dernière modification : de root
