## Search found 301 matches

Thu Jul 22, 2021 5:32 pm
Forum: MicroPython
Topic: Cycling up and down in a range
Replies: 18
Views: 382

### Re: Cycling up and down in a range

Very nice, i've pinched that snippet
Thu Jul 22, 2021 5:21 pm
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

Working well, pretty chuffed with this for the time it took, and pile of junkbox bits :D :D :D Code as it stands, not done much tweaking yet... from display import ST7789 from machine import SPI, Pin, Timer, PWM import math, utime, gc # Define trigger and echo pins trigger = Pin(3, Pin.OUT) echo = P...
Thu Jul 22, 2021 3:59 pm
Forum: MicroPython
Topic: Storing a range of results
Replies: 6
Views: 156

### Re: Storing a range of results

May I ask why you need to store index along the entries? It seems kinda unnecessary, since lists already index elements by themselves. If it's because you want to add elements out of order then maybe dictionary would fit better here? I don't and i haven't :D This was the major difference between th...
Thu Jul 22, 2021 3:57 pm
Forum: MicroPython
Topic: Cycling up and down in a range
Replies: 18
Views: 382

### Re: Cycling up and down in a range

Thu Jul 22, 2021 3:47 pm
and his simple conditions is the right answer.

Yay, I got something right
Thu Jul 22, 2021 3:54 pm
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

@ - the display sweep is 90 deg off Just subtract 90 from a b = (a-90) * _D2R @ ~ i have a feeling that moving the zero to be centre of the sweep line is going to be more work than needed here. You are using the default scale (2) and the width is 8. 8*scale = 16. Half of 16 is 8. Just subtract 8 fr...
Thu Jul 22, 2021 3:36 pm
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

That is an impressive little clock demo there, thanks
Thu Jul 22, 2021 11:13 am
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

Just an update, drawing in replies to my many threads :D I now have a rough outline project running and working fairly well, code below, its basically an ultrasonic radar, sensor is mounted on a small servo and sweeps 180deg, sweep shows on LCD It's ugly and clumsy but whatever, it's all just a fun ...
Thu Jul 22, 2021 10:19 am
Forum: MicroPython
Topic: Storing a range of results
Replies: 6
Views: 156

### Re: Storing a range of results

Got it, thanks
my issue was that its just nothing like an array in VB6
Thu Jul 22, 2021 8:09 am
Forum: MicroPython
Topic: Storing a range of results
Replies: 6
Views: 156

### Re: Storing a range of results

You can use a list. You can add, remove, sort the elements. You can extract a slice of some of the elements You may have a look at this https://websitesetup.org/wp-content/uploads/2021/04/Python-cheat-sheet-April-2021.pdf Thanks so i can create a nested list like list = [[0],[0, 0]] Where the fist ...
Thu Jul 22, 2021 6:36 am
Forum: MicroPython
Topic: Storing a range of results
Replies: 6
Views: 156

### Storing a range of results

Stumbling about in the dark, I'm looking for a way to store a range of results. In my VisualBasic days I would use an array like (index, entry1, entry2) I could then add to the array size, check its length, recall an entry by its index etc I have no idea of what this would be in Micropython, but i d...
Wed Jul 21, 2021 5:36 pm
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

Thanks OMG, I'm slowly getting the idea
Wed Jul 21, 2021 5:11 pm
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

Makes sense,, thanks
Wed Jul 21, 2021 4:41 pm
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

d is how many lines in height to make the temporary draw buffer. Let's say you wanted a 16x16 rect and d is 4 ~ you will end up with a buffer for a 16x4 rect that gets drawn height//d times. It's a small optimization. With this example we only draw 1/4th the buffer and therefore only use 1/4th of t...
Wed Jul 21, 2021 12:59 pm
Forum: MicroPython
Topic: Cycling up and down in a range
Replies: 18
Views: 382

### Re: Cycling up and down in a range

Nice, Thanks
Wed Jul 21, 2021 12:51 pm
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

I added text to my st7789 driver. Using your driver, OMG, whats the correct form for calling this function... def rect(self, col:int, x:int, y:int, w:int, h:int, d:int=4) -> None: c = col.to_bytes(2, 'big') d = min(d, h) b = memoryview(bytearray(c*(w*d))) for yy in range(h//d): self.draw_buff(b, x,...
Wed Jul 21, 2021 12:46 pm
Forum: MicroPython
Topic: Cycling up and down in a range
Replies: 18
Views: 382

### Re: Cycling up and down in a range

I looked at range but couldn't figure a way to make it cycle both up and down endlessly :D I am sure there would be some Pythonic way to create infinite and cycling iterators but I have no idea how or whether that would be supported by MicroPython OK, cool, thats sort of reassuring that my clumsy c...
Wed Jul 21, 2021 12:40 pm
Forum: MicroPython
Topic: Cycling up and down in a range
Replies: 18
Views: 382

### Re: Cycling up and down in a range

I have a function defined that gets called as a timer callback, what is a sensible way to cycle a variable within that function within a range of numbers - say from 0 to 100 and back to 0 then repeat ? Thanks Perhaps unwittingly, a possible answer is in the text of your question. range() seems to b...
Wed Jul 21, 2021 12:39 pm
Forum: MicroPython
Topic: Cycling up and down in a range
Replies: 18
Views: 382

### Re: Cycling up and down in a range

I would start with - class BouncingNumber(): def __init__(self, min, max): self.val = min self.min = min self.max = max self.dir = +1 def value(self): return self.val def step(self): if self.val >= self.max: self.val = self.val - 1 self.dir = -1 elif self.val <= self.min: self.val = self.val + 1 se...
Wed Jul 21, 2021 11:35 am
Forum: MicroPython
Topic: Cycling up and down in a range
Replies: 18
Views: 382

### Cycling up and down in a range

I have a function defined that gets called as a timer callback,

what is a sensible way to cycle a variable within that function within a range of numbers - say from 0 to 100 and back to 0 then repeat ?

Thanks
Tue Jul 20, 2021 9:06 pm
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

So i need to be researching FrameBuf then ?? Nope, but if you'd want to use something that's derived from it you might give me the link to your screen and I'll see if I could find a way to get it to work. I bet it's just something wrong with the LCD setup. Well, with the driver and clock demo from ...
Tue Jul 20, 2021 3:38 pm
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

how is the buffer arrived at - "bytearray(115200" please? Width*Height*2 ... Or in this case 240*240*2 (115200). The 2 is how many bytes to use per pixel. My driver uses 16 bits (2 bytes) per pixel. Thanks I make better "things". Yes, you certainly do :D :D I'll get to playing w...
Tue Jul 20, 2021 11:46 am
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

So i need to be researching FrameBuf then ??
Tue Jul 20, 2021 5:42 am
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

Very slick, thanks OMG, Once again it works first time. At the soonest time i will sit and think about what i want and how to do it for my idea, its only an idea as i have about 10 other things on the go at present, the weather is great here and have just rekindled my love of target shooting so i'll...
Mon Jul 19, 2021 6:51 am
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

Thanks again OMG,

that works yet again Ever thought of taking up device driver writing - its nice to see stuff that actually functions unlike a lot of the stuff out there

Just need to figure out what to do with it all now
Sun Jul 18, 2021 11:34 am
Forum: MicroPython
Topic: Help connecting SPI ST7789 lcd
Replies: 45
Views: 959

### Re: Help connecting SPI ST7789 lcd

Thanks OMG, i'll be looking at this but its a bit up there again - seems to be a theme with each idea i come up with

Sun is out so its garden time here