ropod7 / pyboard_drive

22 stars 11 forks source link

printLn() and CharsTest() seems broken. #14

Closed mchobby closed 8 years ago

mchobby commented 8 years ago

Could you check the test script 05a_println.py (about to be merged)? 05a_println.py tests the printLn().

Surprisingly it does not print anymore (on my setup). I do have included the charsTest() (line under comment) which does not product anything at the moment.

Sorry to trouble you with all those issues.

ropod7 commented 8 years ago

Try to call charsTest() from main object without calling initCh(), it's working fine in my tests.

ropod7 commented 8 years ago

And printLn() works to.

mchobby commented 8 years ago

I did downloaded the last driver (from today). Still nothing printing but I did made additional investigation. I did print() debug information on the console from printChar(), see here under.

def printChar(self, char, x, y, cont=False, scale=None):
        if not scale:
            scale = self._fontscale
        font = self._font
        scale = 3 if scale > 3 else scale
        index = str(ord(char))
        chrwidth = len(font[index])
        height = font['height']
        data   = font[index]
        X = self.TFTHEIGHT - y - (height*scale)+scale
        Y = x
        print( '--- %s ---' % char )
        print( 'X,Y = %i, %i' % (X,Y) )
        self._char_orientation()
        print( 'chrwidth, height, scale = %i, %i, %i' % (chrwidth, height,scale) )
        self._fill_bicolor(data, X, Y, chrwidth, height, scale=scale)
        if not cont:
            self._graph_orientation()

while running the 05b_charstest.py example, I do get the following information

--- ! ---
X,Y = 300, 7
chrwidth, height, scale = 1, 14, 1
--- " ---
X,Y = 300, 12
chrwidth, height, scale = 3, 14, 1
--- # ---
X,Y = 300, 19
chrwidth, height, scale = 8, 14, 1
--- $ ---
X,Y = 300, 31
chrwidth, height, scale = 7, 14, 1
--- % ---
X,Y = 300, 42
chrwidth, height, scale = 10, 14, 1

Apparently the X value is outside the screen resolution (240px in width).

X and Y calculation seems calculated for a 90° rotated screen... whereas mine is used with the default orientation (like all example's screenshot).

ropod7 commented 8 years ago

I have to chect it soon. It must to be fixed. Thanks.

ropod7 commented 8 years ago

I understand now what do you mean. This driver without screen rotation feature now. In perspective I have a plans to realize that, using PyBoard accelerometer, and at least with object definition. We must to think obout it, because there might be any troubles with memory. I see it so, that we must to save all widgets using LCD class properties, and recalculate them to every next orientation. Or simply, we may add argument in initialization as 'orientation'. May be it coming soon. If you have a reason right now to usage.

mchobby commented 8 years ago

Just 2 things === default screen orientation === I'm using the driver "out-of-the-box" with my Adafruit TFT. I do not try to hack anything. With my screen, I do have the following configuration my default screen config show in this picture I'm not trying to rotate the screen display...

so the debug X,Y values seems abnormal (X=300 is over the 240px for screen width). So no text does print with println().

Is YOUR screen displaying in the same orientation for X and Y axis than mine?

=== Screen rotation feature === I think that the best would be to use a boolean parameter at initialisation time. So we are not depending for the accelerometer (some pyboard model doesn't have them). Changing orientation while running software may be an option... followed by a reset() + screen redrawing should be enough.

ropod7 commented 8 years ago

=== default screen orientation === Yes, axis X and Y are the same. === Screen rotation feature === Shore, may be it's a good enough, but rotation by accel we may set as a option.

ropod7 commented 8 years ago

Now it's added. Call it just as LCD( portrait=False ) and your x=300 must be in matrix. Than tft width changes from 240 to 320px. And 'y' axis higher point must be at 240px.

Remember, that bmp images are rotating to, they will be resized with new proportion.

I'm working on:

  1. drawCircle - something goes wrong after latest update.
  2. image resize to screen resolution. Large images must to be renderable by PyBoard.
  3. etc.
mchobby commented 8 years ago

That rocks in portrait mode. Thanks for the fix. Great :-)