Friday, December 4, 2020

circuitpython example with text

Now with some text as well (and I grant this python code to the public domain as well.)

import time

import board
import displayio
import digitalio

import vectorio
import gamepadshift
import terminalio

BUTTON_LEFT = 128
BUTTON_UP = 64
BUTTON_DOWN = 32
BUTTON_RIGHT = 16
BUTTON_SELECT = 8
BUTTON_START = 4
BUTTON_A = 2
BUTTON_B = 1

print('About to begin.')
for i in range(3,0,-1):
    print(i)
    time.sleep(0.2)


circle = vectorio.Circle(10)
circle2 = vectorio.Circle(6)

display = board.DISPLAY

palette = displayio.Palette(2)
palette[0] = 0x000000
palette[1] = 0xFFFFFF
palette.make_transparent(0)

def get_char_tile(c, x, y):
    g = terminalio.FONT.get_glyph(ord(c))
    tile = displayio.TileGrid(g.bitmap, pixel_shader=palette,  tile_width=g.width, tile_height=g.height, default_tile=g.tile_index, x=x, y=y)
    return tile

def get_string_group(s, x, y):
    text_w, text_h = terminalio.FONT.get_bounding_box()
    group = displayio.Group(max_size=len(s))
    for i, c in enumerate(s):
        group.append(get_char_tile(c, x+text_w*i, y))
    return group


palette2 = displayio.Palette(2)
palette2[0] = 0xFF0000
palette2[1] = 0x0000FF
palette2.make_transparent(0)

vect = vectorio.VectorShape(shape=circle, pixel_shader=palette)
vect2 = vectorio.VectorShape(shape=circle2, pixel_shader=palette2, x=5, y=-5)
s = get_string_group("Hey World!",15,0)
vect3 = vectorio.VectorShape(shape=vectorio.Rectangle(2, 10), pixel_shader=palette2)

move_group = displayio.Group()
move_group.append(vect)
move_group.append(vect2)
group = displayio.Group()
group.append(move_group)
group.append(s)
group.append(vect3)


display.show(group)
#display.show(group2)

group.x = 20
group.y = 20

pad = gamepadshift.GamePadShift(digitalio.DigitalInOut(board.BUTTON_CLOCK),
                                digitalio.DigitalInOut(board.BUTTON_OUT),
                                digitalio.DigitalInOut(board.BUTTON_LATCH))
button = 0
while button != BUTTON_START:
    button = pad.get_pressed()
    if button & BUTTON_UP == BUTTON_UP:
        move_group.y += -1
    if button & BUTTON_DOWN == BUTTON_DOWN:
        move_group.y += 1
    if button & BUTTON_LEFT == BUTTON_LEFT:
        move_group.x += -1
    if button & BUTTON_RIGHT == BUTTON_RIGHT:
        move_group.x += 1
    time.sleep(0.01)
    move_group.x %= display.width
    move_group.y %= display.height


Simple pybadge circuitpython code example

I just got a pybadge, and I was trying to find an example that used the display but only used the core libraries. I couldn't find one, so here it is. I grant this code to the public domain.

import time

import board
import displayio
import digitalio

import vectorio
import gamepadshift

BUTTON_LEFT = 128
BUTTON_UP = 64
BUTTON_DOWN = 32
BUTTON_RIGHT = 16
BUTTON_SELECT = 8
BUTTON_START = 4
BUTTON_A = 2
BUTTON_B = 1

print('About to begin.')
for i in range(3,0,-1):
    print(i)
    time.sleep(0.2)

circle = vectorio.Circle(10)
circle2 = vectorio.Circle(6)

palette = displayio.Palette(2)
palette[0] = 0x000000
palette[1] = 0xFFFFFF
palette.make_transparent(0)
palette2 = displayio.Palette(2)
palette2[0] = 0xFF0000
palette2[1] = 0x0000FF
palette2.make_transparent(0)

vect = vectorio.VectorShape(shape=circle, pixel_shader=palette)
vect2 = vectorio.VectorShape(shape=circle2, pixel_shader=palette2, x=5, y=-5)

group = displayio.Group()
group.append(vect)
group.append(vect2)
display = board.DISPLAY

display.show(group)

group.x = 20
group.y = 20

pad = gamepadshift.GamePadShift(digitalio.DigitalInOut(board.BUTTON_CLOCK),
                                digitalio.DigitalInOut(board.BUTTON_OUT),
                                digitalio.DigitalInOut(board.BUTTON_LATCH))
button = 0
while button != BUTTON_START:
    button = pad.get_pressed()
    if button == BUTTON_UP:
        group.y += -1
    elif button == BUTTON_DOWN:
        group.y += 1
    elif button == BUTTON_LEFT:
        group.x += -1
    elif button == BUTTON_RIGHT:
        group.x += 1
    time.sleep(0.01)
    group.x %= display.width
    group.y %= display.height

  

Sunday, November 8, 2020

How Trump Changed America

 "Seeking to understand rather than be understood requires a suppression of ego that takes practice. Lots of us are out of practice."

https://fivethirtyeight.com/features/how-trump-changed-america/

Thursday, October 29, 2020

Don't vote for Trump

In 2016 American voters did not know whom they were getting. Now they do. They would be voting for division and lying. They would be endorsing the trampling of norms and the shrinking of national institutions into personal fiefs. They would be ushering in climate change that threatens not only distant lands but Florida, California and America’s heartlands. They would be signalling that the champion of freedom and democracy for all should be just another big country throwing its weight around. Re-election would put a democratic seal on all the harm Mr Trump has done.

https://www.economist.com/leaders/2020/10/29/why-it-has-to-be-biden

Friday, September 25, 2020

MeWe 400 bad request

I have tried to create an account at MeWe multiple times, on two different ISPs spaced months apart (June and September of 2020), on Firefox, Chromium and Safari on Fedora, Ubuntu and macOS and every single time I get a 400 Bad Request when it tries to access
https://mewe.com/api/v3/auth/register

Posting because this in not in their support page, and no one else seems to have posted about this problem.

Please don't vote for Donald Trump

 I request that you do not vote for Donald Trump.

Since he became president, he has demonstrated in many ways that he is not qualified to be president.

There are three main things that President Trump has done that stand out in my mind.

The first was after Mueller testified in congress about Russian attempts to influence the US 2016 elections.  On July 24, 2019, Mueller said "Over the course of my career, I’ve seen a number of challenges to our democracy. The Russian government’s effort to interfere in our election is among the most serious."  What did Trump do after this?  Did he talk to Mitch McConnell and tell him to have the senate figure out how to fix this?  Did Trump talk to the State Department, the CIA, NSA or FBI on how to fix Russian influence?  No, Trump called up the President of the Ukraine and told him to announce an investigation of Joe Biden.  Trump's response to Mueller's warning about foreign interference was to try and create more foreign interference.  (Note: Even if you say or can prove that Mueller never should have started investigating Trump's campaign, my point still stands, Trump has done very little (he did make EO 13848) about the well documented Russian interference in the 2016 election).

The second was the whole set of Trump comments on Slow Down Testing.  On Saturday, June 20th, 2020 he said: "When you do testing to that extent, you’re going to find more people. You’re going to find more cases. So I said to my people, 'Slow the testing down, please!'"  On June 23rd he said he doesn't kid and posted a related tweet.  One of the better ways to get out of this covid-19 problem is to test as much as possible so we find the cases and we can then isolate the people with covid-19 instead of having to isolate everyone.  So Trump suggested to slow down testing, and then repeated it multiple times over the next few days.  In other words, Trump could not figure out how stupid slowing down testing is despite having days to think about it. Trump should have been asking to speed up testing.

The third is honesty.  Trump lies. From the first day in office when he lied about the number of people attending his inauguration to saying that all of Portland is on fire and has been for decades, Trump lies. (I've been to Portland in the past few years, and the city was not burning then and while the riots have occasionally set fires, they are fairly limited, saying the whole city is ablaze was an outright lie.)

So, please do not vote for Trump.

References:

Mueller Testimony:
https://thehill.com/policy/national-security/454481-read-muellers-opening-statement-about-russia-investigation

Mueller Report:
https://www.justice.gov/storage/report_volume1.pdf

https://www.justice.gov/storage/report_volume2.pdf
https://www.justice.gov/storage/report_appendices.pdf

Whistleblower letter about July 25th phone call:
https://intelligence.house.gov/uploadedfiles/20190812_-_whistleblower_complaint_unclass.pdf

EO 13848, Trump's September 12th, 2018 executive order on Foreign Interference:
https://www.whitehouse.gov/presidential-actions/executive-order-imposing-certain-sanctions-event-foreign-interference-united-states-election/

Review of FISA Applications and Other Aspects of the FBI's Crossfire Hurricane Investigation:
https://www.justice.gov/storage/120919-examination.pdf

Trump quips that he told aides to 'slow the testing down' for coronavirus:
https://thehill.com/homenews/campaign/503758-trump-quips-that-he-told-aides-to-slow-the-testing-down-for-coronavirus

Trump: "I don't kid" on coronavirus testing:
https://thehill.com/homenews/administration/504060-trump-i-dont-kid-on-coronavirus-testing

Donald Trump, June 23, 2020: "Cases are going up in the U.S. because we are testing far more than any other country, and ever expanding. With smaller testing we would show fewer cases!"
https://mobile.twitter.com/realDonaldTrump/status/1275381670561095682


Trump on Inaugural Crowd Size:
https://thehill.com/blogs/blog-briefing-room/news/315484-trump-defends-size-of-his-inaugural-crowd

Trump false claims that Portland is on fire and has been for decades:
https://www.politifact.com/factchecks/2020/sep/01/donald-trump/we-are-not-fire-authorities-dispute-trumps-false-c/

Trump claims the Portland on fire "or a city like Portland, where the entire city is ablaze all the time":
https://www.whitehouse.gov/briefings-statements/remarks-president-trump-press-briefing-august-8-31-2020/

A more complete list of Trump's cruelties, collusions, corruptions, and crimes:
https://www.mcsweeneys.net/columns/reasons-why-donald-trump-is-unfit-to-be-president


Tuesday, September 15, 2020

Trump's statements have zero factual value

"People outside the business may not recognize what a step it is, culturally and professionally, for reporters and editors to act on the implications of this reality—the knowledge that what a president or his senior representatives say has exactly zero factual value. If you are trying to inform the public, you’re better off not reporting what this president says, contends, or does, unless there are external indications that it’s true." The Media Learned Nothing From 2016 - The Atlantic