@@ -15,8 +15,8 @@ import (
1515type Config struct {
1616 Width int16 // Width is the display resolution
1717 Height int16
18- LogicalWidth int16 // LogicalWidth must be a multiple of 8 and same size or bigger than Width
19- Rotation Rotation // Rotation is clock-wise
18+ LogicalWidth int16 // LogicalWidth must be a multiple of 8 and same size or bigger than Width
19+ Rotation drivers. Rotation
2020}
2121
2222type Device struct {
@@ -30,10 +30,11 @@ type Device struct {
3030 height int16
3131 buffer []uint8
3232 bufferLength uint32
33- rotation Rotation
33+ rotation drivers. Rotation
3434}
3535
36- type Rotation uint8
36+ // Deprecated: use drivers.Rotation instead.
37+ type Rotation = drivers.Rotation
3738
3839// Look up table for full updates
3940var lutFullUpdate = [30 ]uint8 {
@@ -209,13 +210,13 @@ func (d *Device) DisplayRect(x int16, y int16, width int16, height int16) error
209210 if x < 0 || y < 0 || x >= d .logicalWidth || y >= d .height || width < 0 || height < 0 {
210211 return errors .New ("wrong rectangle" )
211212 }
212- if d .rotation == ROTATION_90 {
213+ if d .rotation == drivers . Rotation90 {
213214 width , height = height , width
214215 x -= width
215- } else if d .rotation == ROTATION_180 {
216+ } else if d .rotation == drivers . Rotation180 {
216217 x -= width - 1
217218 y -= height - 1
218- } else if d .rotation == ROTATION_270 {
219+ } else if d .rotation == drivers . Rotation270 {
219220 width , height = height , width
220221 y -= height
221222 }
@@ -301,27 +302,33 @@ func (d *Device) ClearBuffer() {
301302
302303// Size returns the current size of the display.
303304func (d * Device ) Size () (w , h int16 ) {
304- if d .rotation == ROTATION_90 || d .rotation == ROTATION_270 {
305+ if d .rotation == drivers . Rotation90 || d .rotation == drivers . Rotation270 {
305306 return d .height , d .logicalWidth
306307 }
307308 return d .logicalWidth , d .height
308309}
309310
310- // SetRotation changes the rotation (clock-wise) of the device
311- func (d * Device ) SetRotation (rotation Rotation ) {
311+ // Rotation returns the current rotation of the device.
312+ func (d * Device ) Rotation () drivers.Rotation {
313+ return d .rotation
314+ }
315+
316+ // SetRotation changes the rotation of the device.
317+ func (d * Device ) SetRotation (rotation drivers.Rotation ) error {
312318 d .rotation = rotation
319+ return nil
313320}
314321
315322// xy chages the coordinates according to the rotation
316323func (d * Device ) xy (x , y int16 ) (int16 , int16 ) {
317324 switch d .rotation {
318- case NO_ROTATION :
325+ case drivers . Rotation0 :
319326 return x , y
320- case ROTATION_90 :
327+ case drivers . Rotation90 :
321328 return d .width - y - 1 , x
322- case ROTATION_180 :
329+ case drivers . Rotation180 :
323330 return d .width - x - 1 , d .height - y - 1
324- case ROTATION_270 :
331+ case drivers . Rotation270 :
325332 return y , d .height - x - 1
326333 }
327334 return x , y
0 commit comments