girouettes 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: girouettes
3
+ Version: 0.1.0
4
+ Summary: Pilotage de girouettes LED Hanover et Mobitec via une API Python unifiee.
5
+ Project-URL: Homepage, https://github.com/Ymo90/girouettes
6
+ Project-URL: Repository, https://github.com/Ymo90/girouettes
7
+ Keywords: rs485,hanover,mobitec,led,girouette
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Classifier: Topic :: System :: Hardware
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: pyserial
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest; extra == "dev"
23
+ Requires-Dist: build; extra == "dev"
24
+ Requires-Dist: twine; extra == "dev"
25
+
26
+ # test_girouette
27
+
28
+ Projet Python pour piloter des girouettes LED Hanover et Mobitec avec une API unifiee en francais.
29
+
30
+ ## Structure
31
+
32
+ - girouette/
33
+ - __init__.py
34
+ - erreurs.py
35
+ - hanover.py
36
+ - mobitec.py
37
+ - generique.py
38
+ - tests/
39
+ - conftest.py
40
+ - test_hanover.py
41
+ - test_mobitec.py
42
+ - test_generique.py
43
+ - examples/
44
+ - demo_generique.py
45
+ - demo_horloge.py
46
+ - demo_lecture_texte.py
47
+ - demo_lecture_continue.py
48
+ - docs/
49
+ - guide_debutant.md
50
+ - guide_superx_1_3.pdf
51
+ - hanover_communication_protocol.txt
52
+ - hanover_communications_protocol_0_14.pdf
53
+ - mobitec_protocol.md
54
+ - superx.txt
55
+
56
+ ## Installation
57
+
58
+ 1. Creer et activer un environnement virtuel Python.
59
+ 2. Installer les dependances d'execution:
60
+
61
+ ```bash
62
+ pip install -r requirements.txt
63
+ ```
64
+
65
+ 3. (Optionnel) Installer aussi les dependances de developpement/tests:
66
+
67
+ ```bash
68
+ pip install -r requirements-dev.txt
69
+ ```
70
+
71
+ ## Lancer les tests
72
+
73
+ ```bash
74
+ pytest -q tests/test_hanover.py tests/test_mobitec.py tests/test_generique.py
75
+ ```
76
+
77
+ ## Lancer les exemples
78
+
79
+ Exemple principal (API unifiee):
80
+
81
+ ```bash
82
+ python examples/demo_generique.py
83
+ ```
84
+
85
+ Exemple horloge:
86
+
87
+ ```bash
88
+ python examples/demo_horloge.py
89
+ ```
90
+
91
+ Exemple lecture/affichage d'un texte:
92
+
93
+ ```bash
94
+ python examples/demo_lecture_texte.py "Prochain depart 12:05"
95
+ ```
96
+
97
+ Exemple lecture continue (mise a jour a chaque saisie):
98
+
99
+ ```bash
100
+ python examples/demo_lecture_continue.py
101
+ ```
102
+
103
+ ## Utilisation rapide
104
+
105
+ ```python
106
+ from girouette.generique import GirouetteGenerique
107
+
108
+ with GirouetteGenerique(
109
+ port="COM5",
110
+ type_backend="hanover", # ou "mobitec"
111
+ adresse=2,
112
+ vitesse=4800,
113
+ ) as g:
114
+ g.afficher_texte("BONJOUR", alignement_h="centre")
115
+ ```
116
+
117
+ Acces direct backend Hanover (avance):
118
+
119
+ ```python
120
+ from girouette.hanover import GirouetteHanover
121
+
122
+ with GirouetteHanover("COM5", adresse=2) as g:
123
+ g.afficher("LIGNE 42")
124
+ ```
125
+
126
+ Acces direct backend Mobitec (avance):
127
+
128
+ ```python
129
+ from girouette.mobitec import GirouetteMobitec, Police, AlignementHorizontal
130
+
131
+ with GirouetteMobitec("COM5") as g:
132
+ g.display_text("LIGNE 42", alignment=AlignementHorizontal.CENTRE, font=Police.MOYENNE_13PX)
133
+ ```
134
+
135
+ ## Notes
136
+
137
+ - L'API debutant commune expose: afficher_texte, afficher_deux_lignes, afficher_defilant, effacer, regler_luminosite, lire_statut.
138
+ - Certaines fonctions dependent du backend materiel. Si une fonction n'est pas supportee, une exception explicite est levee.
139
+ - Pour afficher_defilant, la semantique de vitesse differe selon le backend: Mobitec accepte un delai float (ex. 0.08), alors que Hanover n'applique qu'un parametre entier >= 1.
140
+ - Cote Mobitec, les enums francais sont disponibles: `Police`, `AlignementHorizontal`.
141
+ - Les anciens noms anglais restent valides pour compatibilite: `Font`, `Alignment`.
142
+
143
+ ## Mobitec avance (noms francais)
144
+
145
+ En acces direct backend Mobitec, privilegier les methodes francaises:
146
+
147
+ - afficher_multiligne(...)
148
+ - afficher_pixels(...)
149
+ - afficher_clignotant(...)
150
+ - afficher_machine_a_ecrire(...)
151
+ - arreter_animation()
152
+
153
+ Les noms anglais historiques sont conserves pour retrocompatibilite
154
+ (display_multiline, display_pixel_art, display_blinking, display_typewriter,
155
+ stop_current_animation).
156
+
157
+ ## Publier sur PyPI
158
+
159
+ 1. Mettre a jour la version dans `pyproject.toml` et `girouette/__init__.py`.
160
+ 2. Installer les outils de build:
161
+
162
+ ```bash
163
+ pip install -r requirements-dev.txt
164
+ ```
165
+
166
+ 3. Generer les artefacts:
167
+
168
+ ```bash
169
+ python -m build
170
+ ```
171
+
172
+ 4. Verifier les artefacts:
173
+
174
+ ```bash
175
+ python -m twine check dist/*
176
+ ```
177
+
178
+ 5. Publier (token PyPI recommande):
179
+
180
+ ```bash
181
+ python -m twine upload dist/*
182
+ ```
@@ -0,0 +1,157 @@
1
+ # test_girouette
2
+
3
+ Projet Python pour piloter des girouettes LED Hanover et Mobitec avec une API unifiee en francais.
4
+
5
+ ## Structure
6
+
7
+ - girouette/
8
+ - __init__.py
9
+ - erreurs.py
10
+ - hanover.py
11
+ - mobitec.py
12
+ - generique.py
13
+ - tests/
14
+ - conftest.py
15
+ - test_hanover.py
16
+ - test_mobitec.py
17
+ - test_generique.py
18
+ - examples/
19
+ - demo_generique.py
20
+ - demo_horloge.py
21
+ - demo_lecture_texte.py
22
+ - demo_lecture_continue.py
23
+ - docs/
24
+ - guide_debutant.md
25
+ - guide_superx_1_3.pdf
26
+ - hanover_communication_protocol.txt
27
+ - hanover_communications_protocol_0_14.pdf
28
+ - mobitec_protocol.md
29
+ - superx.txt
30
+
31
+ ## Installation
32
+
33
+ 1. Creer et activer un environnement virtuel Python.
34
+ 2. Installer les dependances d'execution:
35
+
36
+ ```bash
37
+ pip install -r requirements.txt
38
+ ```
39
+
40
+ 3. (Optionnel) Installer aussi les dependances de developpement/tests:
41
+
42
+ ```bash
43
+ pip install -r requirements-dev.txt
44
+ ```
45
+
46
+ ## Lancer les tests
47
+
48
+ ```bash
49
+ pytest -q tests/test_hanover.py tests/test_mobitec.py tests/test_generique.py
50
+ ```
51
+
52
+ ## Lancer les exemples
53
+
54
+ Exemple principal (API unifiee):
55
+
56
+ ```bash
57
+ python examples/demo_generique.py
58
+ ```
59
+
60
+ Exemple horloge:
61
+
62
+ ```bash
63
+ python examples/demo_horloge.py
64
+ ```
65
+
66
+ Exemple lecture/affichage d'un texte:
67
+
68
+ ```bash
69
+ python examples/demo_lecture_texte.py "Prochain depart 12:05"
70
+ ```
71
+
72
+ Exemple lecture continue (mise a jour a chaque saisie):
73
+
74
+ ```bash
75
+ python examples/demo_lecture_continue.py
76
+ ```
77
+
78
+ ## Utilisation rapide
79
+
80
+ ```python
81
+ from girouette.generique import GirouetteGenerique
82
+
83
+ with GirouetteGenerique(
84
+ port="COM5",
85
+ type_backend="hanover", # ou "mobitec"
86
+ adresse=2,
87
+ vitesse=4800,
88
+ ) as g:
89
+ g.afficher_texte("BONJOUR", alignement_h="centre")
90
+ ```
91
+
92
+ Acces direct backend Hanover (avance):
93
+
94
+ ```python
95
+ from girouette.hanover import GirouetteHanover
96
+
97
+ with GirouetteHanover("COM5", adresse=2) as g:
98
+ g.afficher("LIGNE 42")
99
+ ```
100
+
101
+ Acces direct backend Mobitec (avance):
102
+
103
+ ```python
104
+ from girouette.mobitec import GirouetteMobitec, Police, AlignementHorizontal
105
+
106
+ with GirouetteMobitec("COM5") as g:
107
+ g.display_text("LIGNE 42", alignment=AlignementHorizontal.CENTRE, font=Police.MOYENNE_13PX)
108
+ ```
109
+
110
+ ## Notes
111
+
112
+ - L'API debutant commune expose: afficher_texte, afficher_deux_lignes, afficher_defilant, effacer, regler_luminosite, lire_statut.
113
+ - Certaines fonctions dependent du backend materiel. Si une fonction n'est pas supportee, une exception explicite est levee.
114
+ - Pour afficher_defilant, la semantique de vitesse differe selon le backend: Mobitec accepte un delai float (ex. 0.08), alors que Hanover n'applique qu'un parametre entier >= 1.
115
+ - Cote Mobitec, les enums francais sont disponibles: `Police`, `AlignementHorizontal`.
116
+ - Les anciens noms anglais restent valides pour compatibilite: `Font`, `Alignment`.
117
+
118
+ ## Mobitec avance (noms francais)
119
+
120
+ En acces direct backend Mobitec, privilegier les methodes francaises:
121
+
122
+ - afficher_multiligne(...)
123
+ - afficher_pixels(...)
124
+ - afficher_clignotant(...)
125
+ - afficher_machine_a_ecrire(...)
126
+ - arreter_animation()
127
+
128
+ Les noms anglais historiques sont conserves pour retrocompatibilite
129
+ (display_multiline, display_pixel_art, display_blinking, display_typewriter,
130
+ stop_current_animation).
131
+
132
+ ## Publier sur PyPI
133
+
134
+ 1. Mettre a jour la version dans `pyproject.toml` et `girouette/__init__.py`.
135
+ 2. Installer les outils de build:
136
+
137
+ ```bash
138
+ pip install -r requirements-dev.txt
139
+ ```
140
+
141
+ 3. Generer les artefacts:
142
+
143
+ ```bash
144
+ python -m build
145
+ ```
146
+
147
+ 4. Verifier les artefacts:
148
+
149
+ ```bash
150
+ python -m twine check dist/*
151
+ ```
152
+
153
+ 5. Publier (token PyPI recommande):
154
+
155
+ ```bash
156
+ python -m twine upload dist/*
157
+ ```
@@ -0,0 +1,40 @@
1
+ """API publique du package girouette."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ from girouette.erreurs import (
6
+ ErreurCapaciteNonSupportee,
7
+ ErreurConnexion,
8
+ ErreurGirouette,
9
+ ErreurParametre,
10
+ ErreurProtocole,
11
+ )
12
+ from girouette.generique import GirouetteGenerique
13
+ from girouette.hanover import Girouette, GirouetteHanover
14
+ from girouette.mobitec import (
15
+ AlignementHorizontal,
16
+ Alignment,
17
+ DisplayConfig,
18
+ Font,
19
+ GirouetteMobitec,
20
+ MobitecDisplay,
21
+ Police,
22
+ )
23
+
24
+ __all__ = [
25
+ "Alignment",
26
+ "AlignementHorizontal",
27
+ "DisplayConfig",
28
+ "ErreurCapaciteNonSupportee",
29
+ "ErreurConnexion",
30
+ "ErreurGirouette",
31
+ "ErreurParametre",
32
+ "ErreurProtocole",
33
+ "Font",
34
+ "Girouette",
35
+ "GirouetteHanover",
36
+ "GirouetteGenerique",
37
+ "GirouetteMobitec",
38
+ "MobitecDisplay",
39
+ "Police",
40
+ ]
@@ -0,0 +1,21 @@
1
+ """Exceptions metier pour le pilotage de girouettes."""
2
+
3
+
4
+ class ErreurGirouette(Exception):
5
+ """Exception de base du domaine girouette."""
6
+
7
+
8
+ class ErreurConnexion(ErreurGirouette):
9
+ """Connexion serie indisponible, timeout, ou absence de reponse."""
10
+
11
+
12
+ class ErreurParametre(ErreurGirouette, ValueError):
13
+ """Parametre utilisateur invalide."""
14
+
15
+
16
+ class ErreurProtocole(ErreurGirouette):
17
+ """Donnee ou trame incompatible avec le protocole."""
18
+
19
+
20
+ class ErreurCapaciteNonSupportee(ErreurGirouette, NotImplementedError):
21
+ """Fonction demandee non supportee par le materiel cible."""
@@ -0,0 +1,116 @@
1
+ """Facade generique en francais pour piloter Hanover ou Mobitec."""
2
+
3
+ from typing import Literal
4
+
5
+ from girouette.hanover import GirouetteHanover
6
+ from girouette.mobitec import DisplayConfig, GirouetteMobitec
7
+ from girouette.erreurs import ErreurParametre
8
+
9
+
10
+ TypeBackend = Literal["hanover", "mobitec"]
11
+
12
+
13
+ class GirouetteGenerique:
14
+ """
15
+ API unifiee et pedagogique pour debutants.
16
+
17
+ Meme surface de methodes quel que soit le materiel physique:
18
+ - afficher_texte
19
+ - afficher_deux_lignes
20
+ - afficher_defilant
21
+ - effacer
22
+ - regler_luminosite
23
+ - lire_statut
24
+ """
25
+
26
+ def __init__(
27
+ self,
28
+ port: str,
29
+ type_backend: TypeBackend,
30
+ adresse: int = 1,
31
+ vitesse: int = 4800,
32
+ timeout: float = 1.0,
33
+ largeur: int = 112,
34
+ hauteur: int = 16,
35
+ ):
36
+ """
37
+ Initialise une girouette avec un backend explicite.
38
+
39
+ Parametres:
40
+ port: port serie, par exemple COM5
41
+ type_backend: hanover ou mobitec
42
+ adresse: adresse logique de l'afficheur
43
+ vitesse: debit en bauds
44
+ timeout: timeout de communication en secondes
45
+ largeur: largeur en pixels (utile pour Mobitec)
46
+ hauteur: hauteur en pixels (utile pour Mobitec)
47
+ """
48
+ self.backend = type_backend
49
+
50
+ if type_backend == "hanover":
51
+ self._impl = GirouetteHanover(port=port, adresse=adresse, vitesse=vitesse, timeout=timeout)
52
+ elif type_backend == "mobitec":
53
+ config = DisplayConfig(width=largeur, height=hauteur, address=adresse)
54
+ self._impl = GirouetteMobitec(port=port, config=config, baudrate=vitesse, timeout=timeout)
55
+ else:
56
+ raise ErreurParametre("type_backend doit valoir 'hanover' ou 'mobitec'.")
57
+
58
+ def __enter__(self):
59
+ """Support du bloc with."""
60
+ return self
61
+
62
+ def __exit__(self, exc_type, exc_val, exc_tb):
63
+ """Fermeture automatique du port serie en sortie de bloc with."""
64
+ self.fermer()
65
+
66
+ def fermer(self):
67
+ """Ferme proprement la connexion selon le backend choisi."""
68
+ if hasattr(self._impl, "fermer"):
69
+ self._impl.fermer()
70
+ return
71
+ if hasattr(self._impl, "close"):
72
+ self._impl.close()
73
+ return
74
+
75
+ def afficher_texte(self, texte: str, alignement_h: str = "centre", alignement_v: str = "centre") -> bool:
76
+ """Affiche un texte simple."""
77
+ if self.backend == "hanover":
78
+ return self._impl.afficher_texte(texte=texte, alignement_h=alignement_h)
79
+ return self._impl.afficher_texte(
80
+ texte=texte,
81
+ alignement_h=alignement_h,
82
+ alignement_v=alignement_v,
83
+ )
84
+
85
+ def afficher_deux_lignes(self, ligne1: str, ligne2: str, alignement_h: str = "centre") -> bool:
86
+ """Affiche un texte sur deux lignes."""
87
+ return self._impl.afficher_deux_lignes(ligne1=ligne1, ligne2=ligne2, alignement_h=alignement_h)
88
+
89
+ def afficher_defilant(self, texte: str, vitesse: float = 0.1,
90
+ direction: str = "gauche", bloquant: bool = False) -> bool:
91
+ """
92
+ Affiche un texte defilant.
93
+
94
+ Note compatibilite backend:
95
+ - Mobitec interprete `vitesse` comme delai entre frames (float, ex. 0.08).
96
+ - Hanover ne supporte pas ce mode temporel: seul un parametre SuperX
97
+ entier est transmis quand `vitesse >= 1`.
98
+ """
99
+ return self._impl.afficher_defilant(
100
+ texte=texte,
101
+ vitesse=vitesse,
102
+ direction=direction,
103
+ bloquant=bloquant,
104
+ )
105
+
106
+ def effacer(self) -> bool:
107
+ """Efface l'afficheur."""
108
+ return self._impl.effacer()
109
+
110
+ def regler_luminosite(self, valeur: int) -> bool:
111
+ """Regle la luminosite si la fonction est supportee."""
112
+ return self._impl.regler_luminosite(valeur)
113
+
114
+ def lire_statut(self) -> dict:
115
+ """Lit le statut si la fonction est supportee."""
116
+ return self._impl.lire_statut()