Skip to content

bbepWriteString() with bbepSetRotation(90) and bbepSetRotation(270) generate same image. #8

Description

@skiphansen

To use panel type EP29R_128x296 as a landscape display it is necessary to rotate the screen.
Rotate works, but the text was upside down so I changed from 90 to 270 but the text was still upside down.
I tired both with a buffer and w/o.

Here's my test code:

int BbTestCmd(char *CmdLine)
{
   char Msg[] = "Hello world";
//   char Msg[] = "Hello";
   int x;
   int y;
   int BB_Type = EP_PANEL_UNDEFINED;
   int Ret = RESULT_OK;
   BBEPDISP bbep;
   int Err;
   time_t StartTime;
   time_t EndTime;
   int Font = FONT_16x16;
   int FontWidth;
   int FontHeight;
   int DisplayWidth;
   int DisplayHeight;
   bool bRotate = false;

   do {
      if(sscanf(CmdLine,"%d",&BB_Type) == 1) {
         if(BB_Type <= EP_PANEL_UNDEFINED || BB_Type >= EP_PANEL_COUNT) {
            Ret = RESULT_USAGE;
            ListBBTypes();
            printf("Invalid argument, type must be > 0 & < %d\n",
                   EP_PANEL_COUNT);
            break;
         }
      }
      else {
      // no argument, list types
         ListBBTypes();
         break;
      }

      if((Err = bbepSetPanelType(&bbep,BB_Type)) != BBEP_SUCCESS) {
         printf("bbepSetPanelType failed %d\n",Err);
         break;
      }
      bbepInitIO(&bbep,8000000);
      if (bbepTestPanelType(&bbep) != bbep.chip_type) { 
         printf("Error: Panel does not match chip type\n");
         break;
      }

#if 0
      if((Err = bbepAllocBuffer(&bbep)) != BBEP_SUCCESS) {
         printf("bbepAllocBuffer failed %d\n",Err);
         break;
      }
#endif

      printf("%s is %d X %d pixels\n",
             gBB_TypeStrings[BB_Type-1],bbep.width,bbep.height);

      DisplayWidth = bbep.width;
      DisplayHeight = bbep.height;
      if(DisplayHeight > DisplayWidth) {
         printf("Setting rotation to 270\n");
         bRotate = true;
         bbepSetRotation(&bbep,270);
         DisplayHeight = bbep.width;
         DisplayWidth = bbep.height;
      }

   // Center message
      while(Font >= FONT_6x8) {
         switch(Font) {
            case FONT_6x8:
               FontWidth = 6;
               FontHeight = 8;
               break;

            case FONT_8x8:
               FontWidth = 8;
               FontHeight = 8;
               break;

            case FONT_12x16:
               FontWidth = 12;
               FontHeight = 16;
               break;

            case FONT_16x16:
               FontWidth = 16;
               FontHeight = 16;
               break;
         }

         if(bRotate) {
            x = (DisplayWidth - FontHeight) / 2;
            y = (DisplayHeight - (sizeof(Msg) * FontWidth)) / 2;
         }
         else {
            x = (DisplayWidth - (sizeof(Msg) * FontWidth)) / 2;
            y = (DisplayHeight - FontHeight) / 2;
         }
         if(x >= 0 && y >=  0) {
         // Fits
            break;
         }
         if(bRotate) {
            if(Font == FONT_16x16) {
               Font = FONT_8x8;
            }
            else if(Font == FONT_8x8) {
               Font = -1;
            }
         }
         else {
            Font--;
         }
      }

      if(Font < 0) {
         printf("Error: test message won't fit on screen!\n");
         break;
      }

      printf("Writing test message @ %d,%d with FONT_%dx%d\n",
             x,y,FontWidth,FontHeight);

      printf("bbepFill plane 0 ...");
      fflush(stdout);
      time(&StartTime);
      bbepFill(&bbep,BBEP_WHITE,0);
      time(&EndTime);
      printf(" %ld secs\nbbepFill plane 1 ...",EndTime - StartTime);
      fflush(stdout);
      time(&StartTime);
      bbepFill(&bbep,BBEP_WHITE,1);
      time(&EndTime);
      printf(" %ld secs\nbbepWriteString ...",EndTime - StartTime);
      fflush(stdout);

      Err = bbepWriteString(&bbep,x,y,Msg,Font,BBEP_BLACK);
      if(Err != BBEP_SUCCESS) {
         printf(" failed %d\n",Err);
         break;
      }

      x += (sizeof(Msg) - 1) * FontWidth;
      Err = bbepWriteString(&bbep,x,y,"!",Font,BBEP_RED);
      if(Err != BBEP_SUCCESS) {
         printf(" failed %d\n",Err);
         break;
      }

      printf("\nbbepRefresh ...");
      fflush(stdout);
      if((Err = bbepRefresh(&bbep,REFRESH_FULL)) != BBEP_SUCCESS) {
         printf(" failed %d\n",Err);
         break;
      }
      fflush(stdout);
      printf("\nbbepWaitBusy\n");
      time(&StartTime);
      bbepWaitBusy(&bbep);
      time(&EndTime);
      printf("Refresh time %ld secs\n",EndTime - StartTime);
      printf("bbepSleep ...");
      fflush(stdout);
      bbepSleep(&bbep,DEEP_SLEEP);
      printf("\nDone\n");
   } while(false);
   return Ret;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions