<commit_before>=head1 NAME

clock.pir - LCD clock

=head1 SYNOPSIS

    ./parrot examples/sdl/lcd/clock.pir

=head1 DESCRIPTION

This example demonstrates the SDL::LCD object. It shows a simple clock.

=head1 FUNCTIONS

=over 4

=cut

.include "tm.pasm"
.include "timer.pasm"

=item _main

The main function.

=cut

.sub _main :main
    load_bytecode "library/SDL/App.pir"
    load_bytecode "library/SDL/Event.pir"
    load_bytecode "library/SDL/EventHandler.pir"
    load_bytecode "library/SDL/LCD.pir"

    # create the SDL application object
    .local pmc app
    app = new 'SDL::App'
    app.'init'( 'height' => 21, 'width' => 94, 'bpp' => 16, 'flags' => 5 )

    .local pmc screen
    screen = app.'surface'()
    set_global 'screen' = screen

    # create the LCD
    .local pmc lcd
    lcd = new 'SDL::LCD'
    set_global 'LCD' = lcd

    # draw the watch
    drawWatch()

    # create the timer
    $P1 = global "drawWatch"
    $P0 = new 'Timer'
    $P0[.PARROT_TIMER_NSEC] = 0.5
    $P0[.PARROT_TIMER_HANDLER] = $P1
    $P0[.PARROT_TIMER_REPEAT] = -1
    $P0[.PARROT_TIMER_RUNNING] = 1
    # store the timer somewhere, it will be
    # collected and destroyed otherwise
    set_global "timer" = $P0

    #
    # event loop
    #
    .local pmc eh
    .local pmc loop

    eh   = new 'SDL::EventHandler'
    loop = new 'SDL::Event'
    loop.'init'()
    loop.'process_events'( 0.1, eh )
.end

=item drawWatch

Creates, sets and redraws the LCD display content.

=cut

.sub drawWatch
    # decode the current time
    $I0 = time
    $P0 = decodelocaltime $I0

    # use a dot or a space?
    $N0 -= $I0<commit_msg>[examples] more clock fixes. If only I could my own clock.<commit_after>=head1 NAME

clock.pir - LCD clock

=head1 SYNOPSIS

    ./parrot examples/sdl/lcd/clock.pir

=head1 DESCRIPTION

This example demonstrates the SDL::LCD object. It shows a simple clock.

=head1 FUNCTIONS

=over 4

=cut

.include "tm.pasm"
.include "timer.pasm"

=item _main

The main function.

=cut

.sub _main :main
    load_bytecode "library/SDL/App.pir"
    load_bytecode "library/SDL/Event.pir"
    load_bytecode "library/SDL/EventHandler.pir"
    load_bytecode "library/SDL/LCD.pir"

    # create the SDL application object
    .local pmc app
    app = new 'SDL::App'
    app.'init'( 'height' => 21, 'width' => 94, 'bpp' => 16, 'flags' => 5 )

    .local pmc screen
    screen = app.'surface'()
    set_global 'screen', screen

    # create the LCD
    .local pmc lcd
    lcd = new 'SDL::LCD'
    set_global 'LCD', lcd

    # draw the watch
    drawWatch()

    # create the timer
    $P1 = get_global "drawWatch"
    $P0 = new 'Timer'
    $P0[.PARROT_TIMER_NSEC] = 0.5
    $P0[.PARROT_TIMER_HANDLER] = $P1
    $P0[.PARROT_TIMER_REPEAT] = -1
    $P0[.PARROT_TIMER_RUNNING] = 1
    # store the timer somewhere, it will be
    # collected and destroyed otherwise
    set_global "timer", $P0

    #
    # event loop
    #
    .local pmc eh
    .local pmc loop

    eh   = new 'SDL::EventHandler'
    loop = new 'SDL::Event'
    loop.'init'()
    loop.'process_events'( 0.1, eh )
.end

=item drawWatch

Creates, sets and redraws the LCD display content.

=cut

.sub drawWatch
    # decode the current time
    $I0 = time
    $P0 = decodelocaltime $I0

    # use a dot or a space?
    $N0 -= $I0
{'fraction_non_alphanumeric': 0.11793313069908815, 'fraction_numerical': 0.01884498480243161, 'mean_word_length': 2.6244493392070485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7628545', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1229, 'n_words': 353}