Thursday, March 5, 2020

MM32 microcontroller specification in tkinter in python


from tkinter import *
import pymysql

def create_table():
    #uart,i2c,spi,adc,eeprom,pack,dac,,usb,can,sdio,comp,aes,trng
    mycursor.execute("CREATE TABLE MM32 (id INT AUTO_INCREMENT PRIMARY KEY, PartNo VARCHAR(255),ARMVer VARCHAR(255), MaxSpeed VARCHAR(255),Flash VARCHAR(255),RAM VARCHAR(255),GPIO VARCHAR(255),AdvTimer VARCHAR(255),GPTM VARCHAR(255),WDG VARCHAR(255),RTC VARCHAR(255),UART VARCHAR(255),I2C VARCHAR(255),SPI VARCHAR(255),ADC VARCHAR(255),EEPROM VARCHAR(255),PACK VARCHAR(255),DAC VARCHAR(255),USB VARCHAR(255),CAN VARCHAR(255),SDIO VARCHAR(255),COMP VARCHAR(255),AES VARCHAR(255),TRNG VARCHAR(255) )")
    print("Table created")

def View_table():
    mycursor.execute("SELECT * FROM MM32")
    row = mycursor.fetchone() 
    while row is not None:
        print(row)
        row = mycursor.fetchone()

conn=pymysql.connect(host="localhost",user="root",password="",db="my_python")
mycursor=conn.cursor()


#main code start here
print("\n1.create a table")
print("\n2.insert into table")
print("\n3.View  table")
x=int(input("enter your choice:::"))
if x==1:
    create_table()
elif x==3:
    View_table()
 
elif x==2:
    sql = "INSERT INTO MM32 (PartNo, ARMVer, MaxSpeed,Flash,RAM,GPIO,AdvTimer,GPTM,WDG,RTC,UART,I2C,SPI,ADC,EEPROM,PACK,DAC,USB,CAN,SDIO,COMP,AES,TRNG) VALUES (%s, %s ,%s,%s, %s ,%s,%s,%s, %s ,%s,%s, %s ,%s,%s,%s,%s,%s,%s, %s ,%s,%s, %s ,%s)"
    PartNo=input("enter mm32 part")
    ARMVer=input("enter your arm_version")
    MaxSpeed=input("enter your MaxSpeed")
    Flash=input("enter your Flash")
    RAM=input("enter your RAM")
    GPIO=input("enter your GPIO")
    AdvTimer=input("enter your AdvTimer")
    GPTM=input("enter your GPTM")
    WDG=input("enter your WDG")
    RTC=input("enter your RTC")
    UART=input("enter your UART")
    I2C=input("enter your I2C")
    SPI=input("enter your SPI")
    ADC=input("enter your ADC")
    EEPROM=input("enter your EEPROM")
    PACK=input("enter your PACK")
    DAC=input("enter your DAC")
    USB=input("enter your USB")
    CAN=input("enter your CAN")
    SDIO=input("enter your SDIO")#COMP,AES,TRNG
    COMP=input("enter your COMP")
    AES=input("enter your AES")
    TRNG=input("enter your TRNG")
    val = (PartNo, ARMVer,MaxSpeed,Flash,RAM,GPIO,AdvTimer,GPTM,WDG,RTC,UART,I2C,SPI,ADC,EEPROM,PACK,DAC,USB,CAN,SDIO,COMP,AES,TRNG)
    mycursor.execute(sql, val)
    print(mycursor.rowcount, "record inserted.")
#mycursor.execute(sql, val1)
else :
    print("please enter above options only")

conn.commit()

output:

1.create a table

2.insert into table

3.View  table

enter your choice:::3
(1, 'MM32F003TW', 'CORTEX-M0', '48Mhz', '16Kbytes', '2Kbytes', '16', '1', '5', '2', '-', '1', '1', '1', '8x12-bit', '-', 'TSSOP20', '-', '-', '-', '-', '-', '-', '-')
(2, 'MM32F003NW', 'CORTEX-M0', '48MHZ', '16kbytes', '2kbytes', '16', '1', '5', '2', '-', '1', '1', '1', '8x12-bit ', '-', 'QFN20', '-', '-', '-', '-', '-', '-', '-')

How to insert data into my sql using python language using menu program


from tkinter import *
import pymysql

def create_table():
    mycursor.execute("CREATE TABLE MM32 (id INT AUTO_INCREMENT PRIMARY KEY, PartNo VARCHAR(255),ARMVer VARCHAR(255), MaxSpeed VARCHAR(255),Flash VARCHAR(255),RAM VARCHAR(255),GPIO VARCHAR(255),AdvTimer VARCHAR(255),GPTM VARCHAR(255),WDG VARCHAR(255),RTC VARCHAR(255) )")
    print("Table created")

def View_table():
    mycursor.execute("SELECT * FROM MM32")
    row = mycursor.fetchone() 
    while row is not None:
        print(row)
        row = mycursor.fetchone()

conn=pymysql.connect(host="localhost",user="root",password="",db="sslabs")
mycursor=conn.cursor()


#main code start here
print("\n1.create a table")
print("\n2.insert into table")
print("\n3.View  table")
x=int(input("enter your choice:::"))
if x==1:
    create_table()
elif x==3:
    View_table()
 
elif x==2:
    sql = "INSERT INTO MM32 (PartNo, ARMVer, MaxSpeed,Flash,RAM,GPIO,AdvTimer,GPTM,WDG,RTC) VALUES (%s, %s ,%s,%s, %s ,%s,%s,%s, %s ,%s)"
    PartNo=input("enter mm32 part")
    ARMVer=input("enter your arm_version")
    MaxSpeed=input("enter your MaxSpeed")
    Flash=input("enter your Flash")
    RAM=input("enter your RAM")
    GPIO=input("enter your GPIO")
    AdvTimer=input("enter your AdvTimer")
    GPTM=input("enter your GPTM")
    WDG=input("enter your WDG")
    RTC=input("enter your RTC")
    val = (PartNo, ARMVer,MaxSpeed,Flash,RAM,GPIO,AdvTimer,GPTM,WDG,RTC)
    mycursor.execute(sql, val)
    print(mycursor.rowcount, "record inserted.")
#mycursor.execute(sql, val1)
else :
    print("please enter above options only")

conn.commit()

window with rectangle circle and line using pygame library in python



# Import a library of functions called 'pygame'
import pygame

# Initialize the game engine
pygame.init()

# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)

PI = 3.141592653

# Set the height and width of the screen
#size = (400, 500)
size = (500, 700)
screen = pygame.display.set_mode(size)

pygame.display.set_caption("Professor Craven's Cool Game")

# Loop until the user clicks the close button.
done = False
clock = pygame.time.Clock()

# Loop as long as done == False
while not done:

    for event in pygame.event.get():  # User did something
        if event.type == pygame.QUIT:  # If user clicked close
            done = True  # Flag that we are done so we exit this loop

    # All drawing code happens after the for loop and but
    # inside the main while not done loop.

    # Clear the screen and set the screen background
    screen.fill(WHITE)

    # Draw on the screen a line from (0,0) to (100,100)
    # 5 pixels wide.
    pygame.draw.line(screen, GREEN, [0, 0], [100, 100], 5)
    pygame.draw.line(screen, GREEN, [0, 0], [100, 100], 10)

    # Draw on the screen several lines from (0,10) to (100,110)
    # 5 pixels wide using a loop
    for y_offset in range(0, 100, 10):
        pygame.draw.line(screen, RED, [0, 10 + y_offset], [100, 110 + y_offset], 5)


    # Draw a rectangle
    pygame.draw.rect(screen, BLACK, [20, 20, 250, 100], 2)

    # Draw an ellipse, using a rectangle as the outside boundaries
    pygame.draw.ellipse(screen, BLACK, [20, 20, 250, 100], 2)

    # Draw an arc as part of an ellipse.
    # Use radians to determine what angle to draw.
    pygame.draw.arc(screen, BLACK, [20, 220, 250, 200], 0, PI / 2, 2)
    pygame.draw.arc(screen, GREEN, [20, 220, 250, 200], PI / 2, PI, 2)
    pygame.draw.arc(screen, BLUE, [20, 220, 250, 200], PI, 3 * PI / 2, 2)
    pygame.draw.arc(screen, RED, [20, 220, 250, 200], 3 * PI / 2, 2 * PI, 2)

    # This draws a triangle using the polygon command
    pygame.draw.polygon(screen, BLACK, [[100, 100], [0, 200], [200, 200]], 5)

    # Select the font to use, size, bold, italics
    font = pygame.font.SysFont('Calibri', 25, True, False)

    # Render the text. "True" means anti-aliased text.
    # Black is the color. This creates an image of the
    # letters, but does not put it on the screen
    text = font.render("ANIL DURGAM", True, BLACK)

    # Put the image of the text on the screen at 250x250
    screen.blit(text, [90, 300])

    # Go ahead and update the screen with what we've drawn.
    # This MUST happen after all the other drawing commands.
    pygame.display.flip()

    # This limits the while loop to a max of 60 times per second.
    # Leave this out and we will use all CPU we can.
    clock.tick(60)

# Be IDLE friendly
pygame.quit()




example 2:


# Import a library of functions called 'pygame'
import pygame

# Initialize the game engine
pygame.init()

# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)

PI = 3.141592653

# Set the height and width of the screen
#size = (400, 500)
size = (500, 700)
screen = pygame.display.set_mode(size)

pygame.display.set_caption("Professor Craven's Cool Game")

# Loop until the user clicks the close button.
done = False
clock = pygame.time.Clock()

# Loop as long as done == False
while not done:

    for event in pygame.event.get():  # User did something
        if event.type == pygame.QUIT:  # If user clicked close
            done = True  # Flag that we are done so we exit this loop

    # All drawing code happens after the for loop and but
    # inside the main while not done loop.

    # Clear the screen and set the screen background
    screen.fill(WHITE)

    # Draw on the screen a line from (0,0) to (100,100)
    # 5 pixels wide.
    pygame.draw.line(screen, GREEN, [0, 0], [100, 100], 5)
    pygame.draw.line(screen, GREEN, [0, 0], [100, 100], 10)

    # Draw on the screen several lines from (0,10) to (100,110)
    # 5 pixels wide using a loop
    for y_offset in range(0, 100, 10):
        pygame.draw.line(screen, RED, [0, 10 + y_offset], [100, 110 + y_offset], 5)


    # Draw a rectangle
    pygame.draw.rect(screen, BLACK, [20, 20, 250, 100], 2)

    # Draw an ellipse, using a rectangle as the outside boundaries
    pygame.draw.ellipse(screen, BLACK, [20, 20, 250, 100], 2)

    # Draw an arc as part of an ellipse.
    # Use radians to determine what angle to draw.
    pygame.draw.arc(screen, BLACK, [20, 220, 250, 200], 0, PI / 2, 2)
    pygame.draw.arc(screen, GREEN, [20, 220, 250, 200], PI / 2, PI, 2)
    pygame.draw.arc(screen, BLUE, [20, 220, 250, 200], PI, 3 * PI / 2, 2)
    pygame.draw.arc(screen, RED, [20, 220, 250, 200], 3 * PI / 2, 2 * PI, 2)
   
    ##
    ##
    pygame.draw.arc(screen, BLACK, [30, 220, 250, 200], 0, PI / 2, 2)
    pygame.draw.arc(screen, GREEN, [30, 220, 250, 200], PI / 2, PI, 2)
    pygame.draw.arc(screen, BLUE, [30, 220, 250, 200], PI, 3 * PI / 2, 2)
    pygame.draw.arc(screen, RED, [30, 220, 250, 200], 3 * PI / 2, 2 * PI, 2)
   
    ##
    ##
    pygame.draw.arc(screen, BLACK, [40, 220, 250, 200], 0, PI / 2, 2)
    pygame.draw.arc(screen, GREEN, [40, 220, 250, 200], PI / 2, PI, 2)
    pygame.draw.arc(screen, BLUE, [40, 220, 250, 200], PI, 3 * PI / 2, 2)
    pygame.draw.arc(screen, RED, [40, 220, 250, 200], 3 * PI / 2, 2 * PI, 2)
   
    ##
    ##
    pygame.draw.arc(screen, BLACK, [50, 220, 250, 200], 0, PI / 2, 2)
    pygame.draw.arc(screen, GREEN, [50, 220, 250, 200], PI / 2, PI, 2)
    pygame.draw.arc(screen, BLUE, [50, 220, 250, 200], PI, 3 * PI / 2, 2)
    pygame.draw.arc(screen, RED, [50, 220, 250, 200], 3 * PI / 2, 2 * PI, 2)

    # This draws a triangle using the polygon command
    pygame.draw.polygon(screen, BLACK, [[100, 100], [0, 200], [200, 200]], 5)
     # This draws a triangle using the polygon command
    pygame.draw.polygon(screen, BLUE, [[100, 150], [0, 200], [200, 200]], 5)
    #pygame.draw.circle()
    # Select the font to use, size, bold, italics
    font = pygame.font.SysFont('Calibri', 25, True, False)

    # Render the text. "True" means anti-aliased text.
    # Black is the color. This creates an image of the
    # letters, but does not put it on the screen
    text = font.render("ANIL DURGAM", True, BLACK)

    # Put the image of the text on the screen at 250x250
    screen.blit(text, [90, 300])

    # Go ahead and update the screen with what we've drawn.
    # This MUST happen after all the other drawing commands.
    pygame.display.flip()

    # This limits the while loop to a max of 60 times per second.
    # Leave this out and we will use all CPU we can.
    clock.tick(60)

# Be IDLE friendly
pygame.quit()

pygame_demo_window in python


import pygame

# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)

pygame.init()

# Set the width and height of the screen [width, height]
size = (700, 500)
screen = pygame.display.set_mode(size)

pygame.display.set_caption("My Game")

# Loop until the user clicks the close button.
done = False

# Used to manage how fast the screen updates
clock = pygame.time.Clock()

# -------- Main Program Loop -----------
while not done:
    # --- Main event loop
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True

    # --- Game logic should go here

    # --- Screen-clearing code goes here

    # Here, we clear the screen to white. Don't put other drawing commands
    # above this, or they will be erased with this command.

    # If you want a background image, replace this clear with blit'ing the
    # background image.
    screen.fill(GREEN)

    # --- Drawing code should go here

    # --- Go ahead and update the screen with what we've drawn.
    pygame.display.flip()

    # --- Limit to 60 frames per second
    clock.tick(60)

# Close the window and quit.
pygame.quit()

python class topic video