Autor Tema: Driver Grafico LCD para FreeRTOS  (Leído 4549 veces)

0 Usuarios y 2 Visitantes están viendo este tema.

Desconectado Darukur

  • Colaborador
  • PIC18
  • *****
  • Mensajes: 464
    • Informacion, recursos y ejemplos para desarrollos con microcontroladores
Driver Grafico LCD para FreeRTOS
« en: 02 de Mayo de 2009, 19:14:30 »
Despues de mucho tiempo que lo colgue al tema este, aca subo un ejemplo para uso de la libreria grafica LCD para FreeRTOS (y la libreria en si).
Utilizo el conocido G12864 pero se puede configurar para modelos con diferentes tamaños de pantalla.
En el ejemplo uso un AT91SAM7S pero la idea era que corriera sobre picmicro tambien (cosa que no la continue porque me dio muchos dolores de cabeza) pero es realizable.
Otros micros tambien se pueden agregar, solo habria q trabajar sobre la capa de abstraccion.
Las librerias son de libre uso educativo, no se permite uso comercial de las mismas. Se permite mejorarlas pero se debe hacer mencion al autor original (osea yo).
A continuacion subo un videito para mostrar como quedo, hacia tiempo que las habia terminado pero nunca me habia puesto a hacer el video...


La placa para el AT91SAM7 que uso es una que desarrollamos en el foro de sistemas embebidos asi como la placa de desarrollo con el LCD.
Saludos espero que les sirva y escucho sus comentarios!

Link al tema
Link al codigo

El que no sabe lo que busca no entiende lo que encuentra.
Mi Pagina Web:  http://www.sistemasembebidos.com.ar
Mi foro:             http://www.sistemasembebidos.com.ar/foro/

Desconectado Nocturno

  • Administrador
  • DsPIC33
  • *******
  • Mensajes: 18286
    • MicroPIC
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #1 en: 02 de Mayo de 2009, 19:47:59 »
Te ha quedado chulísimo, Marcelo. Felicidades

Una curiosidad: ¿porqué escribes en inglés?

Desconectado Darukur

  • Colaborador
  • PIC18
  • *****
  • Mensajes: 464
    • Informacion, recursos y ejemplos para desarrollos con microcontroladores
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #2 en: 02 de Mayo de 2009, 22:15:04 »
Es un vicio del trabajo :), en la empresa se habla, se escribe y se programa en ingles y obviamente esas cosas se trasladan sin querer al ambito particular.
Ademas porque como soy fiel al concepto GNU, si comparto en mi idioma natal excluyo a la gente que habla otros idiomas y siendo el ingles un idioma universal lo veo facil para que lo entiendan otras personas.

Igual, si tienen alguna dudilla, obviamente las contestare en castellano :P

Lo que mas me agrada de lo hecho es que cada tarea que se hace se puede hacer en una instancia separada (por ejemplo una instancia de ventana de texto), esta tendria sus propios limites de escritura, su fuente, etc que no afectaria a ninguna otra posible instancia.
Lo que no sabia como decidirme era con respecto a hacerlo thread safe, osea correr multiples instancias al mismo tiempo en hilos separados. Por un lado tenia la preocupacion de que anduviera rapido y aprovechara optimizaciones relacionadas al tipo de display, y por otro que permitiese por ejemplo hacer tareas de dibujo en dos areas separadas sin que traiga incongruencias.

Esta pensado como para que una tarea primitiva se encargue de la serializacion del quantum minimo de ejecucion pero obviamente el costo es tiempo de proceso...

Saludos!
El que no sabe lo que busca no entiende lo que encuentra.
Mi Pagina Web:  http://www.sistemasembebidos.com.ar
Mi foro:             http://www.sistemasembebidos.com.ar/foro/

Desconectado gera

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2188
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #3 en: 02 de Mayo de 2009, 23:04:55 »
Felicitaciones Darukur!!! esta espectacular!!! :-/
Veo q sabes mucho de sistemas operativos y estas a favor del movimiento del soft libre :). Solo por curiosidad, estudiaste alguna carrera relacionada? En donde estas trabajando?
Yo estoy en 4º año de ingenieria en computacion, y soy muy fanatico del movimiento GNU y Linux :lol:, espero poder trabajar en algo relacionado cuando me reciba jeje.
bueno, me fui de tema jeje, saludos y gracias por compartir tus logros!!!

"conozco dos cosas infinitas: el universo y la estupidez humana. Y no estoy muy seguro del primero." A.Einstein

Desconectado AKENAFAB

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3227
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #4 en: 02 de Mayo de 2009, 23:10:32 »

Buenisimo trabajo!

Un saludo!


Desconectado Darukur

  • Colaborador
  • PIC18
  • *****
  • Mensajes: 464
    • Informacion, recursos y ejemplos para desarrollos con microcontroladores
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #5 en: 03 de Mayo de 2009, 13:10:08 »
Felicitaciones Darukur!!! esta espectacular!!! :-/
Veo q sabes mucho de sistemas operativos y estas a favor del movimiento del soft libre :). Solo por curiosidad, estudiaste alguna carrera relacionada? En donde estas trabajando?
Yo estoy en 4º año de ingenieria en computacion, y soy muy fanatico del movimiento GNU y Linux :lol:, espero poder trabajar en algo relacionado cuando me reciba jeje.
bueno, me fui de tema jeje, saludos y gracias por compartir tus logros!!!
Sabes que es toda una historia... Desde chico me gusto la electronica pero mas relacionado a las tecnicas digitales, asi que estudie electronica, pero nunca me desligue del soft.
Me gusta el software de bajo nivel, los drivers, los sistemas operativos en tiempo real y los OS bien dichos.
Estoy trabajando en una empresa que es conocida por su tecnologia de semiconductores pero ahora desarrolla software tambien (la de algo inside... :) )

Salutes!
El que no sabe lo que busca no entiende lo que encuentra.
Mi Pagina Web:  http://www.sistemasembebidos.com.ar
Mi foro:             http://www.sistemasembebidos.com.ar/foro/

Desconectado gera

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2188
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #6 en: 03 de Mayo de 2009, 14:50:20 »
Sabes que es toda una historia... Desde chico me gusto la electronica pero mas relacionado a las tecnicas digitales, asi que estudie electronica, pero nunca me desligue del soft.
Me gusta el software de bajo nivel, los drivers, los sistemas operativos en tiempo real y los OS bien dichos.
Estoy trabajando en una empresa que es conocida por su tecnologia de semiconductores pero ahora desarrolla software tambien (la de algo inside... :) )

Salutes!

Jaja, voy por el mismo camino. De chico me gustaba mucho programar, y despues descubri el mundo de la electronica. Y que mejor que el firmware para dedicarme a los dos. La verdad q no me arrepiento en absoluto de haber elegido computacion y no informatica jeje. Espero tener suerte y terminar trabajando en algo como vos :lol:
saludos!!!

"conozco dos cosas infinitas: el universo y la estupidez humana. Y no estoy muy seguro del primero." A.Einstein

Desconectado Darukur

  • Colaborador
  • PIC18
  • *****
  • Mensajes: 464
    • Informacion, recursos y ejemplos para desarrollos con microcontroladores
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #7 en: 03 de Mayo de 2009, 18:20:13 »
Un detalle... El proyecto se debe locacionar dentro de la carpeta de la distribucion de FreeRTOS.
En mi caso hice una carpeta Projects a la misma altura que Demo (que es parte de la distribucion).
Saludos.
El que no sabe lo que busca no entiende lo que encuentra.
Mi Pagina Web:  http://www.sistemasembebidos.com.ar
Mi foro:             http://www.sistemasembebidos.com.ar/foro/

Desconectado Darukur

  • Colaborador
  • PIC18
  • *****
  • Mensajes: 464
    • Informacion, recursos y ejemplos para desarrollos con microcontroladores
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #8 en: 27 de Junio de 2009, 13:14:35 »
Actualize el driver de LCD debido a que habia algo que no lo habia pensado (o no le habia prestado mucha atencion).
Muchos recursos que se le solicita al RTOS los maneja utilizando sus propias implementaciones de malloc() y free(), y cuenta con 3 modelos para las mismas:

    * Uno simple donde se solicita memoria antes de que comienze el RTOS, luego no se devuelve nunca dicha memoria
    * Uno que permite manejar memoria dinamicamente (pidiendo y devolviendo) pero que no desfragmenta la memoria
    * Uno mas completo que el anterior que si desfragmenta la memoria


Para estos dispositivos se recomienda el modelo 2, ya que el 3 es muy consumidor en cpu y memoria.

Como uso modelo 2 se recomienda usar para cada tarea el mismo tamaño de stack, de manera de que cuando se devuelve dicha memoria otro puede tomar este mismo segmento.

El tema era que yo en el driver de LCD creaba y destruia semaforos dinamicamente para bloquear cada tarea, ya que es un desperdicio reservar memoria en semaforos para tantos tipos de tareas.
El problema era que me fragmentaba la memoria y dependiendo de los tiempos podia entrar en starvation y negarte de hacer algo...

El modelo nuevo usa solo 3 niveles de mutex y eventos para resolverlo, el costo... un tipo de tarea a la vez...

Abajo pongo la version actualizada.

Saludos!
El que no sabe lo que busca no entiende lo que encuentra.
Mi Pagina Web:  http://www.sistemasembebidos.com.ar
Mi foro:             http://www.sistemasembebidos.com.ar/foro/

Desconectado Darukur

  • Colaborador
  • PIC18
  • *****
  • Mensajes: 464
    • Informacion, recursos y ejemplos para desarrollos con microcontroladores
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #9 en: 27 de Junio de 2009, 14:06:45 »
Aca dejo como ejemplo el codigo de la demo:

Programa principal
Código: C
  1. int main( void )
  2. {
  3.     /* Setup the ports */
  4.     prvSetupHardware();
  5.  
  6.     /*Initialize LCD*/
  7.     vGlcdInit();
  8.  
  9.     /*Tasks Start-up*/
  10.     xTaskCreate( vLcdDemo, "LcdDemo", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, &xLcdDemoHandle );
  11.    
  12.     /*Start the scheduler.
  13.     NOTE : Tasks run in system mode and the scheduler runs in Supervisor mode.
  14.     The processor MUST be in supervisor mode when vTaskStartScheduler is
  15.     called.  The demo applications included in the FreeRTOS.org download switch
  16.     to supervisor mode prior to main being called.  If you are not using one of
  17.     these demo application projects then ensure Supervisor mode is used here. */
  18.     vTaskStartScheduler();
  19.  
  20.     /* Should never get here! */
  21.     return 0;
  22. }

El codigo para el marco (ya que lo uso mucho lo hice funcion)
Código: C
  1. static void vLcdDemoFrame( void *pvParameters )
  2. {
  3.     for ( ; ; )
  4.     {
  5.         /*Init fillscreen object*/
  6.         fillScr.offset.x = fillScr.offset.y = 0; //Offset for the source in X and Y
  7.         fillScr.param.color = PX_COMB_PASTE; //Coloring method
  8.         fillScr.size.x = fillScr.size.y = 1; //One byte long in X and Y
  9.         fillScr.data = pclean; //Source of the data
  10.         /*Call to the method "Clear all screen"*/
  11.         cGlcdFillScr( &fillScr );
  12.  
  13.         /*Init bitmap object*/
  14.         bitmap.param.limited = 0; //Limit to screen size
  15.         bitmap.param.optimized = 1; //Optimized routine
  16.         bitmap.source.size.x = 64; bitmap.source.size.y = 12; //Size of the bitmap source
  17.         bitmap.size = bitmap.source.size; //Size of the desired bitmap
  18.         bitmap.source.offset.x = bitmap.source.offset.y = 0;
  19.         bitmap.pos.x = bitmap.pos.y = 0; //Position of bitmap
  20.         bitmap.param.color = PX_COMB_PASTE;
  21.         bitmap.source.data = pframeleft;
  22.         /*Call to the method "place bitmap"*/
  23.         cGlcdBitmapSet( &bitmap );
  24.  
  25.         bitmap.pos.x = 64; bitmap.pos.y = 51;
  26.         /*Call to the method "place bitmap"*/
  27.         cGlcdBitmapSet( &bitmap );
  28.  
  29.         bitmap.pos.x = 64; bitmap.pos.y = 0;
  30.         bitmap.source.data = pframeright;
  31.         /*Call to the method "place bitmap"*/
  32.         cGlcdBitmapSet( &bitmap );
  33.  
  34.         bitmap.pos.x = 0; bitmap.pos.y = 51;
  35.         /*Call to the method "place bitmap"*/
  36.         cGlcdBitmapSet( &bitmap );
  37.  
  38.         /*Init text object*/
  39.         text.window.pos.x = 0;
  40.         text.window.pos.y = 13; //Position of the text window
  41.         text.window.size.x = 128;
  42.         text.window.size.y = 38; //Size of the text window
  43.         text.string.pos.x = text.string.pos.y = 0; // Initial position of text in the window
  44.         text.string.param.color = PX_COMB_PASTE;
  45.         text.string.param.optimized = 1;
  46.         text.string.param.limited = 1;
  47.         text.string.tabspace = xGlcdGetDefTAB(4); // Size of tab space
  48.         text.font.size.x = 7; text.font.size.y = 8; //Size of font
  49.         text.font.data = font7_8;
  50.        
  51.         /*Resume the main task*/
  52.         vTaskResume( xLcdDemoHandle );
  53.  
  54.         /*Destroy this task*/
  55.         vTaskDelete( xTaskGetCurrentTaskHandle() );
  56.     }
  57. }

La demo en si:
Código: C
  1. static void vLcdDemo( void *pvParameters )
  2. {
  3. unsigned portCHAR cnt;
  4.     for ( ; ; )
  5.     {
  6.         /*General LCD task blocktime*/
  7.         vGlcdSetBlockTime(300);
  8.  
  9.         /*Create a common frame for text*/
  10.         xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
  11.        
  12.         /*Suspend until completion of task*/
  13.         vTaskSuspend( xLcdDemoHandle );
  14.  
  15.         text.string.data = "\fGraphic LCD driver\n\tfor FreeRTOS\n";//Text to display
  16.  
  17.         /*Call to the method "print text in window"*/
  18.         cGlcdPrintf( &text );
  19.         text.font.size.x = 5; text.font.size.y = 6; //Size of font
  20.         text.font.data = font5_6;
  21.         text.string.pos.y += 4;
  22.         text.string.data = "All Right reserved\nMarcelo Lorenzati - 2009";
  23.         /*Call to the method "print text in window"*/
  24.         cGlcdPrintf( &text );
  25.  
  26.         /*Showing FillScreen*/
  27.         vTaskDelay( 3000 );
  28.         xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
  29.         vTaskSuspend( xLcdDemoHandle );
  30.         text.string.data = "\fFunction:FillScreen\n";
  31.         cGlcdPrintf( &text );
  32.         text.font.size.x = 5; text.font.size.y = 6;
  33.         text.font.data = font5_6;
  34.         text.string.data = "This function fills the\nwhole screen with a tile\noptimized in byte blocks.\nThe initial offset can be configured.";
  35.         cGlcdPrintf( &text );
  36.         vTaskDelay( 5000);
  37.         text.string.data = "\fIf the source is smaller\nthan the the screen, the\nimage is repeated in x\nand y.\nIf it is bigger it´s cho-\npped.";
  38.         cGlcdPrintf( &text );
  39.         vTaskDelay( 5000);
  40.  
  41.         fillScr.data = pthunder;
  42.         fillScr.size.x = 128;
  43.         fillScr.size.y = 8;
  44.         for (cnt = 0; cnt < 128; cnt += 2)
  45.         {
  46.             fillScr.offset.x = cnt;
  47.             cGlcdFillScr( &fillScr );
  48.             vTaskDelay( 50 );
  49.         }
  50.         fillScr.offset.x = 0;
  51.         for (cnt = 0; cnt <= 8; cnt++)
  52.         {
  53.             fillScr.offset.y = cnt;
  54.             cGlcdFillScr( &fillScr );
  55.             vTaskDelay( 100 );
  56.         }
  57.         vTaskDelay( 1000 );
  58.         fillScr.data = pball;
  59.         fillScr.size.x = 16;
  60.         fillScr.size.y = 2;
  61.         for (cnt = 0; cnt <= 64; cnt += 2)
  62.         {
  63.             fillScr.offset.x = cnt;
  64.             fillScr.offset.y = cnt >> 4;
  65.             cGlcdFillScr( &fillScr );
  66.             vTaskDelay( 100 );
  67.         }
  68.  
  69.         vTaskDelay( 2000 );        
  70.  
  71.         /*Showing Pixel*/
  72.         xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
  73.         vTaskSuspend( xLcdDemoHandle );
  74.         text.string.data = "\fFunction:Pixel\n";
  75.         cGlcdPrintf( &text );
  76.         text.font.size.x = 5; text.font.size.y = 6;
  77.         text.font.data = font5_6;
  78.         text.string.data = "This function plots a pix\nel or get its from the\nposition to store in a var";
  79.         cGlcdPrintf( &text );
  80.         vTaskDelay( 5000);
  81.         text.string.data = "\fThe colors are ON, OFF\nand NOT.";
  82.         cGlcdPrintf( &text );
  83.         vTaskDelay( 3000);
  84.         cGlcdFillScr( &fillScr );
  85.         pixel.param.limited = 0; pixel.param.optimized = 1;
  86.         pixel.param.getSet = SET; //We want to set the pixel
  87.         pixel.param.color = PX_COMB_ON; //We want to set the pixel
  88.         for (cnt = 0; cnt < 128; cnt ++)
  89.         {
  90.             pixel.pos.x = cnt; pixel.pos.y = getsin(cnt);
  91.             cGlcdPixel( &pixel );
  92.         }
  93.         for (cnt = 0; cnt < 64; cnt ++)
  94.         {
  95.             pixel.pos.x = cnt + 63; pixel.pos.y = 63 - psin[ cnt ];
  96.             cGlcdPixel( &pixel );
  97.         }
  98.         vTaskDelay( 1000 );
  99.         vGlcdCls(text);
  100.         text.string.data = "Pixel Set\n";
  101.         cGlcdPrintf( &text );
  102.         vTaskDelay( 3000 );
  103.         cGlcdFillScr( &fillScr );
  104.        
  105.         rectangle.posIni.x = 20; rectangle.posFin.x = 106;
  106.         rectangle.posIni.y = 0;  rectangle.posFin.y = 63;
  107.         rectangle.param.color = PX_COMB_ON;
  108.         rectangle.param.getSet = SET;
  109.         rectangle.param.limited = 1; rectangle.param.optimized = 1;
  110.         cGlcdRectangle( &rectangle);
  111.         cGlcdLine( &line1);
  112.  
  113.         cnt=0;
  114.         pixel.pos.x = 21; pixel.pos.y = 2;
  115.         while (cnt <= 30)
  116.         {
  117.             pixel.param.getSet = GET; //We want to get the pixel
  118.             cGlcdPixel( &pixel );
  119.  
  120.             if (pixel.param.color == PX_COMB_ON)
  121.             {
  122.                 switch (cnt & 0x3)
  123.                 {
  124.                     case 0:pixel.pos.x-=4; break;
  125.                     case 1:pixel.pos.y-=4; break;
  126.                     case 2:pixel.pos.x+=4; break;
  127.                     case 3:pixel.pos.y+=4; break;
  128.                 }
  129.                 cnt++;
  130.             }
  131.             else
  132.             {
  133.                 pixel.param.getSet = SET; //We want to set the pixel
  134.                 pixel.param.color = PX_COMB_ON;
  135.                 cGlcdPixel( &pixel );
  136.                 vTaskDelay(5);
  137.             }
  138.  
  139.             switch (cnt & 0x3)
  140.             {
  141.                 case 0:pixel.pos.x++; break;
  142.                 case 1:pixel.pos.y++; break;
  143.                 case 2:pixel.pos.x--; break;
  144.                 case 3:pixel.pos.y--; break;
  145.             }
  146.  
  147.         }
  148.         vTaskDelay( 1000 );
  149.         vGlcdCls(text);
  150.         text.string.data = "Pixel Get\n";
  151.         cGlcdPrintf( &text );
  152.         vTaskDelay( 2000 );
  153.  
  154.         /*Show Line*/
  155.         xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
  156.         vTaskSuspend( xLcdDemoHandle );
  157.         text.string.data = "\fFunction:Line\n";
  158.         cGlcdPrintf( &text );
  159.         text.font.size.x = 5; text.font.size.y = 6;
  160.         text.font.data = font5_6;
  161.         text.string.data = "This function plots a\nline or get the data\nfrom it to store in a bit-array";
  162.         cGlcdPrintf( &text );
  163.         vTaskDelay( 5000);
  164.         cGlcdFillScr( &fillScr );
  165.         line1.param.color = PX_COMB_ON;
  166.         line1.param.getSet = SET;
  167.         line1.param.limited = 1;
  168.         line1.param.optimized = 1;
  169.         for (cnt = 0; cnt <= 127; cnt += 4)
  170.         {
  171.          line1.posIni.x = getsin(cnt);
  172.          line1.posIni.y = getsin(cnt+32);
  173.          line1.posFin.x = getsin(cnt+50);
  174.          line1.posFin.y = getsin(cnt+82);
  175.          cGlcdLine( &line1 );
  176.         }
  177.         text.string.pos.x = 0;text.string.pos.y = 18;
  178.         text.string.data = "This´s a Test\n";
  179.         cGlcdPrintf( &text );
  180.         vTaskDelay( 2000 );
  181.  
  182.         line1.buffer.size = 64;
  183.         line1.buffer.data = bArray;
  184.         for ( cnt = 0u; cnt < 64; cnt ++)
  185.         {
  186.             line1.posIni.x = 0; line1.posIni.y = cnt;
  187.             line1.posFin.x = 63; line1.posFin.y = cnt;
  188.             line1.buffer.index = 0;
  189.             line1.param.getSet = GET;
  190.             cGlcdLine( &line1 );
  191.             line1.posIni.x = cnt + 64; line1.posIni.y = 0;
  192.             line1.posFin.x = cnt + 64; line1.posFin.y = 63;
  193.             line1.buffer.index = 0;
  194.             line1.param.getSet = SET;
  195.             line1.param.color = PX_COMB_NDATA;
  196.             cGlcdLine( &line1 );
  197.         }
  198.  
  199.         vTaskDelay( 1000 );
  200.         vGlcdCls(text);
  201.         text.string.data = "Line Set\t\tLine Get\n";
  202.         cGlcdPrintf( &text );
  203.         vTaskDelay( 2000 );
  204.  
  205.         /*Show Rectangle*/
  206.         xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
  207.         vTaskSuspend( xLcdDemoHandle );
  208.         text.string.data = "\fFunction:Rectangle\n";
  209.         cGlcdPrintf( &text );
  210.         text.font.size.x = 5; text.font.size.y = 6;
  211.         text.font.data = font5_6;
  212.         text.string.data = "This function plots a\nRectangle or gets it´s\ndata to store in an array";
  213.         cGlcdPrintf( &text );
  214.         vTaskDelay(3000);
  215.        
  216.         cGlcdFillScr( &fillScr );
  217.  
  218.         rectangle.param.limited = 1; rectangle.param.optimized = 1;
  219.         rectangle.param.getSet = SET;
  220.         for ( cnt = 0u; cnt < 127; cnt ++)
  221.         {
  222.             rectangle.posIni.x = getsin(2 * cnt);
  223.             rectangle.posFin.x = 64 + getsin(3 * cnt);
  224.             rectangle.posIni.y = getsin(5 * cnt-128);
  225.             rectangle.posFin.y = getsin(4 * cnt-64);
  226.             rectangle.param.color = PX_COMB_ON;
  227.             cGlcdRectangle( &rectangle);
  228.             vTaskDelay( 100 );
  229.             rectangle.param.color = PX_COMB_OFF;
  230.             cGlcdRectangle( &rectangle);
  231.         }
  232.  
  233.         /*Show Circle*/
  234.         xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
  235.         vTaskSuspend( xLcdDemoHandle );
  236.         text.string.data = "\fFunction:Circle\n";
  237.         cGlcdPrintf( &text );
  238.         text.font.size.x = 5; text.font.size.y = 6;
  239.         text.font.data = font5_6;
  240.         text.string.data = "This function plots a\nCircle giving it the\nradius and position";
  241.         cGlcdPrintf( &text );
  242.         vTaskDelay(3000);
  243.        
  244.         cGlcdFillScr( &fillScr );
  245.  
  246.         circle.param.limited = 1; circle.param.optimized = 1;
  247.         circle.param.getSet = SET;
  248.         for ( cnt = 0u; cnt < 127; cnt ++)
  249.         {
  250.             circle.pos.x = 2 * getsin(2 * cnt);
  251.             circle.pos.y = getsin(3 * cnt);
  252.                circle.radio = getsin(4 * cnt);
  253.             circle.param.color = PX_COMB_ON;
  254.             cGlcdCircle( &circle );
  255.             vTaskDelay( 100 );
  256.             circle.param.color = PX_COMB_OFF;
  257.             cGlcdCircle( &circle );
  258.         }
  259.  
  260.         /*Show FloodFill*/
  261.         xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
  262.         vTaskSuspend( xLcdDemoHandle );
  263.         text.string.data = "\fFunction:FloodFill\n";
  264.         cGlcdPrintf( &text );
  265.         text.font.size.x = 5; text.font.size.y = 6;
  266.         text.font.data = font5_6;
  267.         text.string.data = "This function fills the\nobject respecting its\nborders";
  268.         cGlcdPrintf( &text );
  269.         vTaskDelay(3000);
  270.        
  271.         cGlcdFillScr( &fillScr );
  272.  
  273.         fillScr.size.x = 128;
  274.         fillScr.size.y = 8;
  275.         fillScr.data = plaberinth;
  276.         fillScr.param.color = PX_COMB_PASTE;
  277.         cGlcdFillScr( &fillScr );
  278.  
  279.         vTaskDelay( 1000 );
  280.  
  281.         floodFill.size = TEST_FLOODFILL_MAX;
  282.         floodFill.data = testfloodFill;
  283.         floodFill.pos.x = 63;
  284.         floodFill.pos.y = 5;
  285.         floodFill.param.color = PX_COMB_ON;
  286.         floodFill.param.limited = 1;
  287.         floodFill.param.optimized = 1;
  288.        
  289.         /*This task takes long so I increase its maximum block time*/
  290.         vGlcdSetBlockTime(2000);
  291.         cGlcdFloodFill( &floodFill );
  292.        
  293.         vGlcdSetBlockTime(300);
  294.         vTaskDelay(3000);    
  295.  
  296.         /*Show Bitmap*/
  297.         xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
  298.         vTaskSuspend( xLcdDemoHandle );
  299.         text.string.data = "\fFunction:Bitmap\n";
  300.         cGlcdPrintf( &text );
  301.         text.font.size.x = 5; text.font.size.y = 6;
  302.         text.font.data = font5_6;
  303.         text.string.data = "This function places or\nreads a bitmap in a\nspecific position";
  304.         cGlcdPrintf( &text );
  305.         vTaskDelay(3000);
  306.  
  307.         fillScr.data = pthunder;
  308.         fillScr.size.x = 128;
  309.         fillScr.size.y = 8;
  310.         fillScr.offset.x = 0;
  311.         cGlcdFillScr( &fillScr );
  312.  
  313.         bitmap.param.limited = 1;
  314.         bitmap.param.optimized = 1;
  315.         gbitmap.param.limited = 1;
  316.         gbitmap.param.optimized = 1;
  317.         gbitmap.size.x = 16;
  318.         gbitmap.size.y = 16;
  319.         bitmap.size = gbitmap.size;
  320.         bitmap.source.size = gbitmap.size;
  321.         gbitmap.pos.y = 0;
  322.         bitmap.source.offset.x = 0;
  323.         bitmap.source.offset.y = 0;
  324.         for ( cnt = 0u; cnt < 253u; cnt++ )
  325.         {
  326.             gbitmap.pos.x = (unsigned int ) 2 * getsin(2 * cnt) * (128-gbitmap.size.x) / 128;
  327.             gbitmap.pos.y = (unsigned int ) (getsin(5 * cnt) * (64-gbitmap.size.y)) / 64;
  328.             gbitmap.data = gbuffer;
  329.             cGlcdBitmapGet( &gbitmap );
  330.  
  331.             bitmap.pos = gbitmap.pos;
  332.             bitmap.param.color = PX_COMB_XOR;
  333.             bitmap.source.data = pball;
  334.             cGlcdBitmapSet( &bitmap );
  335.  
  336.             vTaskDelay( 50 );
  337.            
  338.             bitmap.param.color = PX_COMB_PASTE;
  339.             bitmap.source.data = gbuffer;
  340.             cGlcdBitmapSet( &bitmap );
  341.         }
  342.  
  343.         /*Show Text Window*/
  344.         xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
  345.         vTaskSuspend( xLcdDemoHandle );
  346.         text.string.data = "\fFunction:wind.text\n";
  347.         cGlcdPrintf( &text );
  348.         text.font.size.x = 5; text.font.size.y = 6;
  349.         text.font.data = font5_6;
  350.         text.string.data = "This function place text\ninside a XY window with\nany kind of font";
  351.         cGlcdPrintf( &text );
  352.         vTaskDelay(3000);
  353.        
  354.         cGlcdFillScr( &fillScr );
  355.  
  356.         rectangle.posIni.x = 0;
  357.         rectangle.posIni.y = 0;
  358.         rectangle.posFin.x = 62;
  359.         rectangle.posFin.y = 63;
  360.         rectangle.param.color = PX_COMB_ON;
  361.         rectangle.param.getSet = SET;
  362.         rectangle.param.limited = 0;
  363.         rectangle.param.optimized = 1;
  364.         cGlcdRectangle( &rectangle );
  365.  
  366.         rectangle.posIni.x = 65;
  367.         rectangle.posIni.y = 0;
  368.         rectangle.posFin.x = 127;
  369.         rectangle.posFin.y = 63;
  370.         cGlcdRectangle( &rectangle );
  371.  
  372.         text.window.pos.x = 1;
  373.         text.window.pos.y = 1;
  374.         text.window.size.x = 61;
  375.         text.window.size.y = 61;
  376.         text.string.pos.x = 0;
  377.         text.string.pos.y = 0;
  378.         text.string.param.color = PX_COMB_PASTE;
  379.         text.string.param.optimized = 1;
  380.         text.string.param.limited = 1;
  381.         text.string.tabspace = xGlcdGetDefTAB(4);
  382.         text.string.data = "\fThis text is on a particular window, the number 1";
  383.         text.font.size.x = 7;
  384.         text.font.size.y = 8;    
  385.         text.font.data = font7_8;  
  386.         cGlcdPrintf( &text );
  387.  
  388.         text.window.pos.x = 66;
  389.         text.string.pos.x = 0;
  390.         text.string.pos.y = 0;
  391.         text.string.data = "\fThis other text is on another window, the number 2";
  392.         cGlcdPrintf( &text );
  393.  
  394.         vTaskDelay(2000);
  395.  
  396.         rectangle.posIni.x = 31;
  397.         rectangle.posIni.y = 15;
  398.         rectangle.posFin.x = 95;
  399.         rectangle.posFin.y = 47;
  400.         cGlcdRectangle( &rectangle );
  401.  
  402.         text.window.pos.x = rectangle.posIni.x + 1;
  403.         text.window.pos.y = rectangle.posIni.y + 1;
  404.         text.window.size.x = xGlcdSizeof(rectangle, x);
  405.         text.window.size.y = xGlcdSizeof(rectangle, y);
  406.         text.window.size.x -= 1;
  407.         text.window.size.y -= 1;
  408.         text.string.pos.x = 0;
  409.         text.string.pos.y = 0;
  410.         text.font.size.x = 5; text.font.size.y = 6;
  411.         text.font.data = font5_6;
  412.         text.string.data = "\fAnd this one is window 3,\nisn´t it\ngreat?";
  413.         cGlcdPrintf( &text );
  414.  
  415.         vTaskDelay(3000);
  416.  
  417.         xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
  418.         vTaskSuspend( xLcdDemoHandle );
  419.         text.string.data = "\fGraphic LCD driver\n\tfor FreeRTOS\n"; //Text to display
  420.         cGlcdPrintf( &text );
  421.         text.font.size.x = 5; text.font.size.y = 6; //Size of font
  422.         text.font.data = font5_6;
  423.         text.string.pos.y += 4;
  424.         text.string.data = "All Right reserved\nMarcelo Lorenzati - 2009";
  425.         cGlcdPrintf( &text );
  426.  
  427.         vTaskDelete( xLcdDemoHandle );
  428.     }
  429. }
El que no sabe lo que busca no entiende lo que encuentra.
Mi Pagina Web:  http://www.sistemasembebidos.com.ar
Mi foro:             http://www.sistemasembebidos.com.ar/foro/

Desconectado Nocturno

  • Administrador
  • DsPIC33
  • *******
  • Mensajes: 18286
    • MicroPIC
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #10 en: 27 de Junio de 2009, 18:13:37 »
Está magnífico.
¿Sabes si costaría mucho adaptarlo a PIC?

Desconectado Darukur

  • Colaborador
  • PIC18
  • *****
  • Mensajes: 464
    • Informacion, recursos y ejemplos para desarrollos con microcontroladores
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #11 en: 28 de Junio de 2009, 00:11:50 »
Hola Nocturno, lo empece en un PIC18, pero tuve mas problemas con el port de PIC18 y el FreeRTOS que con el driver de LCD.
Si te fijas en el header file lo pense como para poder ser usado en otros micros (tiene una HAL).

Código: C
  1. /*IO Ports definition*/
  2. #ifdef KEIL_SAM7
  3. #define PORT_INDEX          0
  4. #define DATA_GET()          ( (unsigned int) AT91F_PIO_GetInput( AT91C_BASE_PIOA ) >> PORT_INDEX ) & 0xFF
  5. #define DATA_SET(x)         AT91F_PIO_SetOutput( AT91C_BASE_PIOA, ( (unsigned int) (x & 0xFF) << PORT_INDEX ) ); \
  6.                             AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, ( (unsigned int) ( (~x) & 0xFF) << PORT_INDEX ) )      
  7. #define DATA_IO_GET()       AT91F_PIO_CfgInput( AT91C_BASE_PIOA, ( (unsigned int) 0xFF << PORT_INDEX ) )
  8. #define DATA_IO_SET()       AT91F_PIO_CfgOutput( AT91C_BASE_PIOA, ( (unsigned int) 0xFF << PORT_INDEX ) )
  9. #define DATA_OP_DRAIN()     AT91C_BASE_PIOA->PIO_MDER =  ( (unsigned int) 0xFF << PORT_INDEX )
  10. #define DATA_DIS_PULLUP()   AT91C_BASE_PIOA->PIO_PPUDR = ( (unsigned int) 0xFF << PORT_INDEX )
  11. #endif
  12.  
  13.  
  14. /*Control Lines definition*/
  15. #ifdef KEIL_SAM7
  16. #define PIN_POS(z)          ((unsigned int) 0x1 <<  z)
  17. #define CTRL_DIS_PULLUP(y)  AT91C_BASE_PIOA->PIO_PPUDR = PIN_POS(y)
  18. #define CTRL_OP_DRAIN(y)    AT91C_BASE_PIOA->PIO_MDER = PIN_POS(y)
  19. #define CTRL_IO(x,y)        CTRL_DIS_PULLUP(y);CTRL_OP_DRAIN(y);                            \
  20.                             if (x) {AT91F_PIO_CfgInput( AT91C_BASE_PIOA, PIN_POS(y) );  }   \
  21.                             else {AT91F_PIO_CfgOutput( AT91C_BASE_PIOA, PIN_POS(y) );   }
  22. #define CTRL_SET(x,y)       if (x) {AT91F_PIO_SetOutput(AT91C_BASE_PIOA, PIN_POS(y) ); } \
  23.                             else {AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, PIN_POS(y) ); }
  24. #define CTRL_GET(x)         AT91F_PIO_IsInputSet( AT91C_BASE_PIOA, PIN_POS(x))
  25. #endif

Lo mas molesto del port de PIC para freeRTOS es que cada vez que compilas tenes que verificar cambios en el archivo .map (.tmpdata y MATHDATA) ya que el C18 utiliza un mapa de memoria para algunas cosas y el RTOS las debe guardar en el stack.

Saludos
El que no sabe lo que busca no entiende lo que encuentra.
Mi Pagina Web:  http://www.sistemasembebidos.com.ar
Mi foro:             http://www.sistemasembebidos.com.ar/foro/

Desconectado japifer_22

  • PIC18
  • ****
  • Mensajes: 405
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #12 en: 28 de Junio de 2009, 03:09:03 »
hola Darukur me sorprende lo que as logrado programar felisidades, jijiji me rio un poco por que yo al igual que varios desde que empese a ver leguajesde programacion en la universidad me gusto pero tuve el dessagrado q

Desconectado japifer_22

  • PIC18
  • ****
  • Mensajes: 405
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #13 en: 28 de Junio de 2009, 03:15:04 »
ue mis profesores en esta area era justo un loco que no savia ni a donde estaba parado ya que el que justo hacia ese entonces se enfermo y bla bla bla...., bueno y simpre quede con la vala paa de programar, buen oyo estudio electronica, y desde un tiempo empese fuerte a darle a la programacion soy un novato en esto comparados con varios o muchos que sirculan este foro constantemente, pero bueno por algo se empiesa, y de nuevo felisidades.......
por otra parte ase una semana que empese a pensar como sera hacer un osciloscopio con pic, se podra ?????? con que pic?? bueno a ver si en algun momento despues que termine lo que estoy asiendo me vanco en eso saludos.....

perdon pase a apretar enviar XD

Desconectado Darukur

  • Colaborador
  • PIC18
  • *****
  • Mensajes: 464
    • Informacion, recursos y ejemplos para desarrollos con microcontroladores
Re: Driver Grafico LCD para FreeRTOS
« Respuesta #14 en: 28 de Junio de 2009, 23:34:53 »
Hice tambien el driver de USART para FRERTOS, aca.
Ahora empece con el driver de SPI con DMA para FREERTOS, la idea es terminarlo y probarlo con un gestor de archivos FAT16/FAT32 que este pensado para embedded como el de ChaN´s FAT ChaN´s FAT

Salutes
El que no sabe lo que busca no entiende lo que encuentra.
Mi Pagina Web:  http://www.sistemasembebidos.com.ar
Mi foro:             http://www.sistemasembebidos.com.ar/foro/