Thursday, April 8, 2021

MM32F MCUs delay in ms(milli seconds) and us(microseconds)

static u8 fac_us = 0;
 static u16 fac_ms = 0;
 extern u32 SystemCoreClock;
 void delay_init() 
 SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
 fac_us = SystemCoreClock / 8000000;
 fac_ms = (u16)fac_us * 1000; } void delay_us(u32 nus) { u32 temp; SysTick->LOAD = nus * fac_us; SysTick->VAL = 0x00; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk ; do { temp = SysTick->CTRL; } while((temp & 0x01) && !(temp & (1 << 16))); SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->VAL = 0X00; } void delay_ms(u16 nms) { u32 temp; SysTick->LOAD = (u32)nms * fac_ms; SysTick->VAL = 0x00; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk ; do { temp = SysTick->CTRL; } while((temp & 0x01) && !(temp & (1 << 16))); SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->VAL = 0X00; }

Tuesday, April 6, 2021

input function in python

# -*- coding: utf-8 -*- """ Created on Tue Apr 6 22:22:06 2021 @author: Onyx1 #input from the user #syntax:input() a=input() b=input() print(a+b) a=int(input("please enter number") ) #string type b=int(input("please enter number ")) #string type print(a,type(a)) print(b,type(b)) print(a+b) a=input("enter your name") print(a, type(a)) a =float(input("please enter floating values")) print(a,type(a)) a= int(input("enter number")) print(a,type(a)) """ #raw_input------python 2.x version input

doc string in python

""" #docstring def basha(): ''' company name:Harish company author:Harish program description: addition , substraction, multiplication functions file date of started:06-04-2021 date modified:08-04-2022 second user: '''''' print("Basha") #__doc__ -------> docstring print(basha.__doc__) ''' def basha1(): """ company_name:Harish company author:Harish program description: addition , substraction, multiplication functions file date of started:06-04-2021 date modified:08-04-2022 second user: """ print("Basha") #__doc__ -------> docstring print(type(basha1)) print(basha1.__doc__) '''

Monday, April 5, 2021

operators in python

""" Created on Mon Apr 5 21:18:07 2021 @author: Onyx1 #class-3-05-04-2021 #addition a=10 b=20 print(a+b) #substraction print(b-a) print(a-b) #multiplication print(a*b) #division print(a/b) #floor division print(a//b) #power print(a**b) #python 2.x print("anl") #operators #arthimatic operation #assignment operators #logical operators #conditional #identify #membership #bitwise #arthimatic operation # +,-,*,/,%,//,**---> operators #assignment operators a=10 b=20 a=a+b b=b-a a=a*b print(a) b=30+50 print("b-",b) a=20 b=10 a=a/b print(a) a=20 b=10 a=a//b print(a) a=20 b=10 a=a**b print(a) #logical operators #& | ! #and a=4#0100 b=2#0010 a = a & b print(a) a=10#1010 b=8#1000 a = a & b print(a) a=4 #0100 b=2 #0010 harish=a|b #0110--6 print(harish) #not....not available a=2 #0010 a!=3 #0011 print(a) #conditional operator a=5 a==5 #5==5 if (a==5): print("this is harish") a>5 #comparison greater than a<4 #comparison less than a<=5 #less than or equal to a>=10 # greater than or equal to a!=10 #not equal to #identify #is #is not #is if two values true then return True same object #is not if two value not True then return False same object x=["rose","lilli"] b=["rose","lilli"] a=x #print(a,x) #print(id(a),id(x)) #print(b,id(b)) print(x is a) #true print(x is b) #False print(x is not b)#True print(x is not a)#false """ #membership #in #not in x=["rose","lilli"] print("rose" in x) #if member exist ---true print("chicken" not in x ) #not exist ---true print("lilli" not in x ) #false

Saturday, April 3, 2021

Operations on numbers in python

dd=3
mm=4
yyyy=2021
print(dd,mm,yyyy,end="",sep="kfdjdskjgshgjhsfdjghdsjfg")
print("03-04-2021")
dd=3
mm=4
yyyy=2021
#print("dd-",dd,"mm-",mm,"yyyy-",yyyy,end="",sep="")
#print("03-04-2021")
#print("dd{}-mm-{}-yyyy-{}".format(mm,dd,yyyy))
#print("%d-%d-%d",dd,mm,yyyy)
#print(dd,mm,yyyy)
#boolean=2values
#True----->1
#False---->0
a=True
print(a)
a=False
print(a)
print(True)
print(False)
#operations on number
#+,_,/,%,**,<,>>=,<=,!,!=
#addition---'+'
a=1054545454545454545454421231545313248432132454
b=206545423132468484543545484843415454564545121324874987524154879848544564654564564654548798798
a=a+b
#print(a)
a=a+a+b+a+a+b+b+a+a+b+b+b+b+a+a+b+b+a+a+b+a+b+b+b
b=a+a+b+a+a+b+b+a+a+b+b+b+b+a+a+b+b+a+a+b+a+b+b+b
#print(a+b)
#subtraction ---'-'
a=20
b=10
c=a-b
print(c)
#multiplication---'*'
a=205454564545454545132132156456451234156456451545456456451341
b=10657484564354846454654845645467484546546546
c=454545454546545453423132545454545465456456454554
print(a*b*c)
print(a*b*c*a*b*c)
#BODMAS
#B-brackets
#O-of
#D-division
#M-multiplication
#A-addition
#s--substraction
print((5*4)+10)
#division---'/' a=10
b=2
#print(type(a),type(b))
c=a/b
print(c)
a=10
b=2
#print(type(a),type(b))
c=a/b
print(c)
#floor division
a=11
b=2
#print(type(a),type(b))
c=a//b
print(c)
a=115465454564564545454545454545
b=2
#print(type(a),type(b))
c=a//b
print(c)
#power **
print(2**5)
print((2**5)**2)
print(10**2)
""" print "jyothi laxmi" #2.0
#integer----int
#string-----str
#float------float
#char--------xxxxxx not available

Wednesday, March 24, 2021

python introduction day1

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> 5+10
15
>>> a=5
>>> print(a)
5
>>> print(type(a))

>>> b=10
>>> print(b)
10
>>> print(type(b))

>>> c=a+b
>>> print(c)
15
>>> print(type(c))

>>> a="saikumar"
>>> print(a)
saikumar
>>> print(type(a))

>>> print(id(a))
23484040
>>> print(id(a))
23484040
>>> print(id(b))
1656382704
>>> a=15
>>> a
15
>>> type(a)

>>> id(a)
1656382784
>>> a=20
>>> id(a)
1656382864
>>>

Tuesday, March 16, 2021

django day6 class html input

https://drive.google.com/file/d/1z8wgE8vx-OeX4j-0ii7LjAHMddpDKMNk/view?usp=sharing

Sunday, March 14, 2021

django day 5 view page logic

View.py ===================== from django.shortcuts import render from django.http import HttpResponse # Create your views here. def home(request): #1+2 #HttpResponse("

this is homepage

") #return HttpResponse("

this is test2 app homepage

") user="ranjith" context={'name':user} if user == "chandu": #context={'name':user} return render(request, "home.html", context) elif user == "ranjith": return render(request, "contact.html", {'price':1000}) else: return render(request, "home.html", context) def contact(request): return HttpResponse("

this is app contactpage

") contact.html =========================

HTML Table

Company Contact price
Alfreds Futterkiste Maria Anders {{price}}
Centro comercial Moctezuma Francisco Chang {{price}}
Ernst Handel Roland Mendel Austria
Island Trading Helen Bennett UK
Laughing Bacchus Winecellars Yoshi Tannamuri Canada
Magazzini Alimentari Riuniti Giovanni Rovelli Italy
urls.py =================================== from django.contrib import admin from django.urls import path,include from . import views urlpatterns = [ path('',views.home,name="home"), path('contact',views.contact,name="contact") ]

Monday, March 8, 2021

django day4 first app running

your app urls.py ===================== from django.contrib import admin from django.urls import path,include from . import views urlpatterns = [ path('',views.home,name="home"), path('contact',views.contact,name="contact") ] your app views.py ====================== from django.shortcuts import render from django.http import HttpResponse # Create your views here. def home(request): #1+2 #HttpResponse("

this is homepage

") #return HttpResponse("

this is test2 app homepage

") return render(request, "home.html", {'name': "the king"}) def contact(request): return HttpResponse("

this is app contactpage

") template--home.html ========================

this is templates page home page{{name}}

this is templates page home page{{name}}

this is templates page home page{{name}}

this is templates page home page{{name}}

this is templates page home page{{name}}

this is templates page home page{{name}}

project urls.py ============================= from django.contrib import admin from django.urls import path,include from . import views urlpatterns = [ path('',include('test2.urls')), path('admin/', admin.site.urls), ]

Sunday, March 7, 2021

django day3

#urls.py from django.contrib import admin from django.urls import path,include from . import views urlpatterns = [ path('',views.home,name="home"), path('contact',views.contact,name="contact"), path('aboutus',views.aboutus,name="aboutus"), path('admin/', admin.site.urls), ] #views.py from django.http import HttpResponse def home(request): #1+2 #HttpResponse("

this is homepage

") return HttpResponse("

this is firstpage

") def contact(request): return HttpResponse("

this is contactpage

") def aboutus(request): return HttpResponse("

about page

")

Friday, March 5, 2021

sep, end in print method in python

""" print(10,20,30,sep='@') print(10,20,end='') print(" ", 30) #print(input("enter number")) #print("you opened django server with IP:http://127.0.0.1:8000\n") def ranjith(): print("ranjith is basha") print("chandu is king") ranjith() def connect(): print("you opened django server with IP:http://127.0.0.1:8000\n") def disconnect(): print("it is disconnected") connect() while(1): print("basha") disconnect() i=0 if(i==0): print("rajinikanth") else: print("ramyakrishna") """

python class topic video