Skip to content

Commit

Permalink
added read-only slider + refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
Enzo-Demeulenaere committed Jul 1, 2024
1 parent cdc805c commit 3b3fc06
Show file tree
Hide file tree
Showing 24 changed files with 535 additions and 577 deletions.
32 changes: 15 additions & 17 deletions CoypuIDE/IC7Segment.class.st
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
Class {
#name : 'IC7Segment',
#superclass : 'BlElement',
#name : #IC7Segment,
#superclass : #BlElement,
#instVars : [
'segments',
'digit'
],
#classVars : [
'Digits'
],
#category : 'CoypuIDE-led / 7segment',
#package : 'CoypuIDE',
#tag : 'led / 7segment'
#category : 'CoypuIDE-led / 7segment'
}

{ #category : 'examples' }
{ #category : #examples }
IC7Segment class >> animatedExample [

<script>
Expand All @@ -29,7 +27,7 @@ IC7Segment class >> animatedExample [
elt digit: nil
]

{ #category : 'examples' }
{ #category : #examples }
IC7Segment class >> example [

<script>
Expand All @@ -38,7 +36,7 @@ IC7Segment class >> example [
openInSpace
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
IC7Segment class >> fullExample [

<script>
Expand All @@ -55,7 +53,7 @@ IC7Segment class >> fullExample [
container openInSpace
]

{ #category : 'class initialization' }
{ #category : #'class initialization' }
IC7Segment class >> initialize [

Digits := {
Expand All @@ -71,21 +69,21 @@ IC7Segment class >> initialize [
{ true. true. true. true. false. true. true } "9"}
]

{ #category : 'accessing' }
{ #category : #accessing }
IC7Segment >> digit [

^ digit
]

{ #category : 'accessing' }
{ #category : #accessing }
IC7Segment >> digit: aNumber [

aNumber ifNil: [ self segments do: [ :seg | seg switchOff ]. ^ self ].
digit := aNumber % 10.
self update
]

{ #category : 'initialization' }
{ #category : #initialization }
IC7Segment >> initialize [

super initialize.
Expand All @@ -95,7 +93,7 @@ IC7Segment >> initialize [
self initializeSegments
]

{ #category : 'initialization' }
{ #category : #initialization }
IC7Segment >> initializeSegments [

self segments: {
Expand Down Expand Up @@ -123,25 +121,25 @@ IC7Segment >> initializeSegments [
self addChildren: self segments
]

{ #category : 'accessing' }
{ #category : #accessing }
IC7Segment >> segments [

^ segments
]

{ #category : 'accessing' }
{ #category : #accessing }
IC7Segment >> segments: aCollection [

segments := aCollection
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
IC7Segment >> switchOff [

self segments do: [ :seg | seg switchOff ].
]

{ #category : 'updating' }
{ #category : #updating }
IC7Segment >> update [

self segments with: (Digits at: digit + 1) do: [ :seg :bool |
Expand Down
34 changes: 16 additions & 18 deletions CoypuIDE/IC7SegmentContainer.class.st
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
Class {
#name : 'IC7SegmentContainer',
#superclass : 'BlElement',
#name : #IC7SegmentContainer,
#superclass : #BlElement,
#instVars : [
'value',
'nbDigits',
'digitElements'
],
#category : 'CoypuIDE-led / 7segment',
#package : 'CoypuIDE',
#tag : 'led / 7segment'
#category : 'CoypuIDE-led / 7segment'
}

{ #category : 'examples' }
{ #category : #examples }
IC7SegmentContainer class >> basicExample [

<script>
self new value: 12345; openInSpace
]

{ #category : 'examples' }
{ #category : #examples }
IC7SegmentContainer class >> basicExampleGetsValueChanged [

<script>
Expand All @@ -32,15 +30,15 @@ IC7SegmentContainer class >> basicExampleGetsValueChanged [
elt value: 12.
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
IC7SegmentContainer class >> truncatedExample [

<script>

self new value: 12345678; openInSpace
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
IC7SegmentContainer class >> truncatedExampleGetsResized [

<script>
Expand All @@ -54,19 +52,19 @@ IC7SegmentContainer class >> truncatedExampleGetsResized [
elt nbDigits: 8
]

{ #category : 'evaluating' }
{ #category : #evaluating }
IC7SegmentContainer >> digitElements [

^ digitElements
]

{ #category : 'evaluating' }
{ #category : #evaluating }
IC7SegmentContainer >> digitElements: aCollection [

digitElements := aCollection
]

{ #category : 'initialization' }
{ #category : #initialization }
IC7SegmentContainer >> initialize [

super initialize.
Expand All @@ -78,7 +76,7 @@ IC7SegmentContainer >> initialize [
self nbDigits: 5
]

{ #category : 'initialization' }
{ #category : #initialization }
IC7SegmentContainer >> initializeDigitElements [

| elts |
Expand All @@ -93,21 +91,21 @@ IC7SegmentContainer >> initializeDigitElements [
self updateDisplayedValue
]

{ #category : 'evaluating' }
{ #category : #evaluating }
IC7SegmentContainer >> nbDigits [

^ nbDigits
]

{ #category : 'evaluating' }
{ #category : #evaluating }
IC7SegmentContainer >> nbDigits: aNumber [

aNumber = nbDigits ifTrue: [ ^ self ].
nbDigits := aNumber.
self initializeDigitElements
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
IC7SegmentContainer >> updateDisplayedValue [

1 to: self nbDigits do: [ :i |
Expand All @@ -116,13 +114,13 @@ IC7SegmentContainer >> updateDisplayedValue [
(self digitElements at: self nbDigits - i+1) digit: newValue ]
]

{ #category : 'evaluating' }
{ #category : #evaluating }
IC7SegmentContainer >> value [

^ value
]

{ #category : 'evaluating' }
{ #category : #evaluating }
IC7SegmentContainer >> value: aNumber [

value := aNumber.
Expand Down
20 changes: 9 additions & 11 deletions CoypuIDE/IC7SegmentGeometry.class.st
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
Class {
#name : 'IC7SegmentGeometry',
#superclass : 'BlPolygonGeometry',
#name : #IC7SegmentGeometry,
#superclass : #BlPolygonGeometry,
#instVars : [
'isVertical'
],
#category : 'CoypuIDE-led / 7segment',
#package : 'CoypuIDE',
#tag : 'led / 7segment'
#category : 'CoypuIDE-led / 7segment'
}

{ #category : 'factory' }
{ #category : #factory }
IC7SegmentGeometry class >> horizontal [

^ self new beHorizontal
]

{ #category : 'factory' }
{ #category : #factory }
IC7SegmentGeometry class >> vertical [

^ self new beVertical
]

{ #category : 'initialization' }
{ #category : #initialization }
IC7SegmentGeometry >> beHorizontal [

isVertical := false
]

{ #category : 'initialization' }
{ #category : #initialization }
IC7SegmentGeometry >> beVertical [

isVertical := true
]

{ #category : 'initialization' }
{ #category : #initialization }
IC7SegmentGeometry >> initialize [

super initialize.
isVertical := false.
]

{ #category : 'geometry' }
{ #category : #geometry }
IC7SegmentGeometry >> matchExtent: anExtent [

extent := anExtent.
Expand Down
Loading

0 comments on commit 3b3fc06

Please sign in to comment.