lib/SSD1306/display.rb
# This skips to a newline if the byte is a LF newline,
# otherwise it prints the character, but only if it is
# in fact a character (i.e., ASCII greater than 31).
This skips to a newline if the byte is a LF newline,
otherwise it prints the character, but only if it is
in fact a character .
This skips to a newline if the byte is a LF newline otherwise it prints the character but only if it is in fact a character .
def print_char(b)
      if b == 10
        @cursor.newline
      elsif b > 31
        for i in 0...5
          if @cursor.size == 1
            @buffer[@cursor.buffer_index + i] = FONT[(b*5) + i]
          else
            byte = FONT[(b*5) + i].to_s(2).rjust(8, '0')
            a = byte.chars.each_slice(8/@cursor.size).map(&:join)
            bytes = []
            a.each do |e|
              bytes << e.chars.map {|c| c*(8/e.length)}.join
            end
            bytes = bytes.map {|b| b.to_i(2)}
            bytes.reverse!
            for page in 0...@cursor.size
              for x_interval in 0...@cursor.size
                @buffer[@cursor.buffer_index(page) + i*@cursor.size + x_interval] = bytes[page]
              end
            end
          end
        end
        @cursor.increment
      end
    end
def print_char ( b ) if b == 10 @cursor . newline elsif b > 31 for i in 0 ... 5 if @cursor . size == 1 @buffer [ @cursor . buffer_index + i ] = FONT [ ( b * 5 ) + i ] else byte = FONT [ ( b * 5 ) + i ] . to_s ( 2 ) . rjust ( 8 , '0' ) a = byte . chars . each_slice ( 8 / @cursor . size ) . map ( & :join ) bytes = [ ] a . each do | e | bytes << e . chars . map { | c | c * ( 8 / e . length ) } . join end bytes = bytes . map { | b | b . to_i ( 2 ) } bytes . reverse! for page in 0 ... @cursor . size for x_interval in 0 ... @cursor . size @buffer [ @cursor . buffer_index ( page ) + i * @cursor . size + x_interval ] = bytes [ page ] end end end end @cursor . increment end end
This skips to a newline if the byte is a LF newline,
otherwise it prints the character, but only if it is
in fact a character (i.e., ASCII greater than 31).
This skips to a newline if the byte is a LF newline otherwise it prints the character but only if it is in fact a character ( i . e . ASCII greater than 31 ) .
b