Make scroll work
This commit is contained in:
		@@ -23,6 +23,18 @@ enum class ScreenFont {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// We only support up to 4 arguments for C++ functions - need to pack them on the TS side
 | 
					// We only support up to 4 arguments for C++ functions - need to pack them on the TS side
 | 
				
			||||||
namespace screen {
 | 
					namespace screen {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					void DisplaySetPixel(byte X, byte Y);
 | 
				
			||||||
 | 
					void DisplayClrPixel(byte X, byte Y);
 | 
				
			||||||
 | 
					void DisplayXorPixel(byte X, byte Y);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void pokeScreen() {
 | 
				
			||||||
 | 
					    DisplayXorPixel(0, 0);
 | 
				
			||||||
 | 
					    DisplayXorPixel(0, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//%
 | 
					//%
 | 
				
			||||||
void _drawLine(uint32_t p0, uint32_t p1, Draw mode) {
 | 
					void _drawLine(uint32_t p0, uint32_t p1, Draw mode) {
 | 
				
			||||||
    DMESG("line %x %x %x", p0, p1, mode);
 | 
					    DMESG("line %x %x %x", p0, p1, mode);
 | 
				
			||||||
@@ -57,6 +69,8 @@ void clear() {
 | 
				
			|||||||
//%
 | 
					//%
 | 
				
			||||||
void scroll(int v) {
 | 
					void scroll(int v) {
 | 
				
			||||||
    LcdScroll(v);
 | 
					    LcdScroll(v);
 | 
				
			||||||
 | 
					    pokeScreen(); // missing in ev3-api
 | 
				
			||||||
 | 
					    //LcdUpdate();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Set font for drawText() */
 | 
					/** Set font for drawText() */
 | 
				
			||||||
@@ -64,5 +78,4 @@ void scroll(int v) {
 | 
				
			|||||||
void setFont(ScreenFont font) {
 | 
					void setFont(ScreenFont font) {
 | 
				
			||||||
    LcdSelectFont((uint8_t)font);
 | 
					    LcdSelectFont((uint8_t)font);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,23 +1,36 @@
 | 
				
			|||||||
screen.clear()
 | 
					screen.clear()
 | 
				
			||||||
screen.setFont(ScreenFont.Large)
 | 
					screen.setFont(ScreenFont.Large)
 | 
				
			||||||
screen.drawText(10, 30, "Hello PXT!")
 | 
					screen.drawText(10, 30, "Hello PXT!")
 | 
				
			||||||
screen.drawRect(10, 70, 20, 10, Draw.Fill)
 | 
					 | 
				
			||||||
screen.drawEllipse(40, 40, 20, 10)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
output.setLights(LightsPattern.GreenPulse)
 | 
					screen.drawEllipse(40, 40, 20, 10, Draw.Fill)
 | 
				
			||||||
 | 
					output.setLights(LightsPattern.Orange)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					input.buttonEnter.onEvent(ButtonEvent.Click, () => {
 | 
				
			||||||
 | 
					    screen.clear()
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					input.buttonLeft.onEvent(ButtonEvent.Click, () => {
 | 
				
			||||||
 | 
					    screen.drawRect(10, 70, 20, 10, Draw.Fill)
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					input.buttonRight.onEvent(ButtonEvent.Click, () => {
 | 
				
			||||||
 | 
					    screen.setFont(ScreenFont.Normal)
 | 
				
			||||||
 | 
					    screen.drawText(10, 60, "Bang!")
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
input.buttonDown.onEvent(ButtonEvent.Click, () => {
 | 
					input.buttonDown.onEvent(ButtonEvent.Click, () => {
 | 
				
			||||||
    screen.scroll(10)
 | 
					    screen.scroll(-10)
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
input.buttonUp.onEvent(ButtonEvent.Click, () => {
 | 
					input.buttonUp.onEvent(ButtonEvent.Click, () => {
 | 
				
			||||||
    screen.scroll(-10)
 | 
					    screen.scroll(10)
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for (let i = 0; i < 3; ++i) {
 | 
					for (let i = 0; i < 3; ++i) {
 | 
				
			||||||
    loops.forever(() => {
 | 
					    loops.forever(() => {
 | 
				
			||||||
        let r = Math.randomRange(0, 100)
 | 
					        let r = Math.randomRange(0, 100)
 | 
				
			||||||
        serial.writeValue("R", r)
 | 
					        serial.writeValue("R", r)
 | 
				
			||||||
 | 
					        //screen.drawText(10, 10, `R=${r}`)
 | 
				
			||||||
        loops.pause(1000)
 | 
					        loops.pause(1000)
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
    loops.pause(300)
 | 
					    loops.pause(300)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user