BCD 7 segments

Partagez votre expérience de PureBasic avec les autres utilisateurs.
Ollivier
Messages : 4190
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

BCD 7 segments

Message par Ollivier »

Code : Tout sélectionner

;***********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
InitSprite()
InitKeyboard()
InitMouse()

ExamineDesktops()
dw = DesktopWidth(0)
dh = DesktopHeight(0)
dd = DesktopDepth(0)

Dim b(255)
Dim c(255)
a$ = "0123456789abcdefLa relativite n'est pas qu'une  chose simple.   mov ah,02       mov dl,'A'      Set / Reset     Video   AUXc    mes grelots     Load  a         Store a         C'est la vie    alarme 1845     production      acquittement    and or xor nand "
For i = 1 To Len(a$)
        c(i - 1) = Asc(UCase(Mid(a$, i, 1) ) )
Next

For i = 0 To 255
        b(i) = i
Next
Swap b(32), b(0)
Swap b(33), b(130)
Swap b(34), b(34)
Swap b(39), b(0)
Swap b(43), b(70)
Swap b(44), b(12)
Swap b(45), b(64)
Swap b(46), b(128)
Swap b(47), b(82)
Swap b(48), b(63)
Swap b(49), b(6)
Swap b(50), b(91)
Swap b(51), b(79)
Swap b(52), b(102)
Swap b(53), b(109)
Swap b(54), b(125)
Swap b(55), b(0)
Swap b(56), b(127)
Swap b(57), b(111)
Swap b(61), b(72)
Swap b(63), b(131)
Swap b(64), b(59)
Swap b(65), b(119)
Swap b(66), b(124)
Swap b(67), b(88)
Swap b(68), b(94)
Swap b(69), b(121)
Swap b(70), b(113)
Swap b(71), b(72)
Swap b(72), b(118)
Swap b(73), b(4)
Swap b(74), b(30)
Swap b(75), b(112)
Swap b(76), b(127)
Swap b(77), b(0)
Swap b(78), b(84)
Swap b(79), b(92)
Swap b(80), b(115)
Swap b(81), b(103)
Swap b(82), b(115)
Swap b(83), b(59)
Swap b(84), b(120)
Swap b(85), b(28)
Swap b(86), b(62)
Swap b(87), b(126)
Swap b(88), b(127)
Swap b(89), b(110)
Swap b(90), b(27)
Swap b(91), b(111)
Swap b(92), b(100)
Swap b(93), b(15)
Swap b(94), b(35)
Swap b(95), b(8)
Swap b(96), b(96)

OpenScreen(dw, dh, dd, "")

CreateSprite(0, 512, 512)
If StartDrawing(SpriteOutput(0) )
        DrawingMode(#PB_2DDrawing_AllChannels)
        c = RGBA(0, 255, 0, 255)
        n = 0
        For Y = 0 To 15
                For X = 0 To 15
                        x0 = x
                        y0 = y
                        x0 * 18
                        y0 * 30
                        q = b(c(n) )
                        If q & 1: Line(x0 + 1, y0, 11, 1, c): Line(x0 + 2, y0 + 1, 9, 1, c): Line(x0 + 3, y0 + 2, 7, 1, c): EndIf
                        If q & 32: Line(x0, y0 + 1, 1, 11, c): Line(x0 + 1, y0 + 2, 1, 9, c): Line(x0 + 2, y0 + 3, 1, 7, c): EndIf
                        If q & 2: Line(x0 + 12, y0 + 1, 1, 11, c): Line(x0 + 11, y0 + 2, 1, 9, c): Line(x0 + 10, y0 + 3, 1, 7, c): EndIf
                        If q & 64: Line(x0 + 1, y0 + 12, 11, 1, c): Line(x0 + 2, y0 + 11, 9, 1, c): Line(x0 + 2, y0 + 13, 9, 1, c): EndIf
                        If q & 16: Line(x0, y0 + 13, 1, 11, c): Line(x0 + 1, y0 + 14, 1, 9, c): Line(x0 + 2, y0 + 15, 1, 7, c): EndIf
                        If q & 4: Line(x0 + 12, y0 + 13, 1, 11, c): Line(x0 + 11, y0 + 14, 1, 9, c): Line(x0 + 10, y0 + 15, 1, 7, c): EndIf
                        If q & 8: Line(x0 + 1, y0 + 24, 11, 1, c): Line(x0 + 2, y0 + 23, 9, 1, c): Line(x0 + 3, y0 + 22, 7, 1, c): EndIf
                        If q & 128: Box(x0 + 14, y0 + 22, 3, 3, c): EndIf
                        n + 1
                Next
        Next
        
        StopDrawing()
EndIf

Repeat
        Delay(16)
        ClearScreen(0)
        ExamineKeyboard()
        DisplaySprite(0, 0, 0)
        FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)

CloseScreen()
Avatar de l’utilisateur
Micoute
Messages : 2522
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

Re: BCD 7 segments

Message par Micoute »

Merci beaucoup Ollivier pour ce partage.
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Avatar de l’utilisateur
MLD
Messages : 1103
Inscription : jeu. 05/févr./2009 17:58
Localisation : Bretagne

Re: BCD 7 segments

Message par MLD »

Salut Ollivier

Chouette ton truc
style 1970 modifier 1980 :oops: :lol: :lol:
Avatar de l’utilisateur
venom
Messages : 3072
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: BCD 7 segments

Message par venom »

En effet bel effet. Merci du partage






@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Avatar de l’utilisateur
Kwai chang caine
Messages : 6962
Inscription : sam. 23/sept./2006 18:32
Localisation : Isere

Re: BCD 7 segments

Message par Kwai chang caine »

Souvenirs, souvenirs....
Merci du partage 8)
ImageLe bonheur est une route...
Pas une destination

PureBasic Forum Officiel - Site PureBasic
Avatar de l’utilisateur
Naheulf
Messages : 191
Inscription : dim. 10/mars/2013 22:22
Localisation : France

Re: BCD 7 segments

Message par Naheulf »

Bonjour,
j'ai regardé vite fait le code et il y a une ligne dont je ne voit pas l'utilité :

Code : Tout sélectionner

Swap b(34), b(34)
Si quelqu'un peut m'éclairer je suis preneur.
Ollivier
Messages : 4190
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Re: BCD 7 segments

Message par Ollivier »

C'est un système de déterrage de topic. Et ça marche !
PAPIPP
Messages : 534
Inscription : sam. 23/févr./2008 17:58

Re: BCD 7 segments

Message par PAPIPP »

Il est fort peu probable que les mêmes causes ne produisent pas les mêmes effets.(Einstein)
Et en logique positive cela donne.
Il est très fortement probable que les mêmes causes produisent les mêmes effets.
Ollivier
Messages : 4190
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Re: BCD 7 segments

Message par Ollivier »

Bonjour PAPIPP,

on n'en apprend beaucoup plus à n'être servi que par soi-même.

Là, c'est une mémoire de 128 octets (1024 bits) qui est programmée par 52 swaps soit 728 bits (52*14 bits) donc avec une base mémoire de 1752 bits (1024+728), on a une base de données ASCII 7 bits, casse oblitérée, prête à alimenter des afficheurs BCD 7 segments + LED.
Répondre