source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | whomwah/rqrcode_core | https://github.com/whomwah/rqrcode_core | lib/rqrcode_core/qrcode/qr_multi.rb | Ruby | mit | 48 | main | 211 | # frozen_string_literal: true
module RQRCodeCore
class QRMulti
def initialize(data)
@data = data
end
def write(buffer)
@data.each { |seg| seg.writer.write(buffer) }
end
end
end |
github | whomwah/rqrcode_core | https://github.com/whomwah/rqrcode_core | lib/rqrcode_core/qrcode/qr_math.rb | Ruby | mit | 48 | main | 851 | # frozen_string_literal: true
module RQRCodeCore
class QRMath
module_eval {
exp_table = Array.new(256)
log_table = Array.new(256)
8.times do |i|
exp_table[i] = 1 << i
end
(8...256).each do |i|
exp_table[i] = exp_table[i - 4] \
^ exp_table[i - 5] \
... |
github | whomwah/rqrcode_core | https://github.com/whomwah/rqrcode_core | lib/rqrcode_core/qrcode/qr_util.rb | Ruby | mit | 48 | main | 8,289 | # frozen_string_literal: true
module RQRCodeCore
class QRUtil
PATTERN_POSITION_TABLE = [
[],
[6, 18],
[6, 22],
[6, 26],
[6, 30],
[6, 34],
[6, 22, 38],
[6, 24, 42],
[6, 26, 46],
[6, 28, 50],
[6, 30, 54],
[6, 32, 58],
[6, 34, 62],
... |
github | morishin/image-stitcher | https://github.com/morishin/image-stitcher | image-stitcher.gemspec | Ruby | mit | 48 | master | 467 | Gem::Specification.new do |s|
s.name = 'image-stitcher'
s.version = '0.2.0'
s.summary = "Combine continuous multiple images"
s.description = s.summary
s.authors = ["Shintaro Morikawa"]
s.email = 'sntr92@gmail.com'
s.executables = ['stitch']
s.homepage =
'https://github.co... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | parsi-date.gemspec | Ruby | mit | 48 | master | 1,105 | $:.push File.expand_path('../lib', __FILE__)
require 'version'
Gem::Specification.new do |s|
s.name = 'parsi-date'
s.version = Parsi::Date::VERSION
s.platform = Gem::Platform::RUBY
s.licenses = ['MIT']
s.author = 'Hassan Zamani'
s.email = 'hsn.zamani@gmail.com'
s.homepage ... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | lib/parsi-date-accessors.rb | Ruby | mit | 48 | master | 363 | module Parsi::DateAccessors
def parsi_date_accessor(*names)
names.each do |name|
define_method("#{name}_parsi") do
send(name).to_parsi rescue nil
end
define_method("#{name}_parsi=") do |value|
value = Parsi::Date.parse(value) if value.is_a?(String)
send("#{name}=", value... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | lib/parsi-datetime.rb | Ruby | mit | 48 | master | 6,286 | # encoding: utf-8
#
# parsi-date.rb
#
# Author: Hassan Zamani 2012
module Parsi
# Class representing a date and time.
#
# See the documentation to the file parsi-date.rb for an overview.
#
# DateTime objects are immutable once created.
class DateTime < Date
shared_methods = Module.new do
def zo... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | lib/parsi-date.rb | Ruby | mit | 48 | master | 26,190 | # encoding: utf-8
#
# parsi-date.rb
#
# Author: Hassan Zamani 2012
#
# == Overview
#
# Date class represent a date in persian (jalali) calendar
#
# === Ways of calculating the date.
#
# In common usage, the date is reckoned in years since or before the Common Era
# (Hegira of Muhammad from Mecca to Medina in 622 CE), t... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/strftime_spec.rb | Ruby | mit | 48 | master | 4,451 | # encoding: utf-8
describe "Parsi::Date#strftime" do
it "is able to print the date" do
expect(Parsi::Date.civil(1390, 4, 6).strftime).to be == "1390/04/06"
end
it "is able to print the full day name" do
expect(Parsi::Date.civil(1390, 4, 6).strftime("%A")).to be == "دوشنبه"
end
it "is able to print ... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/accessors_helper_spec.rb | Ruby | mit | 48 | master | 2,120 | require 'active_record'
require 'sqlite3'
require 'json'
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Schema.verbose = false
ActiveRecord::Schema.define do
create_table :models do |t|
t.date :start_date
end
end
class Model < ActiveRecord::Base
extend Parsi... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/week_methods_spec.rb | Ruby | mit | 48 | master | 688 | describe "Parsi::Date#cwday?" do
it "returns the day of calendar week (1-7, Monday is 1)" do
expect(Parsi::Date.civil(1393, 12, 3).cwday).to be == 7
expect(Parsi::Date.civil(1394, 1, 3).cwday).to be == 1
end
end
describe "Parsi::Date#cweek?" do
it "returns the calendar week number (1-53)" do
expect(... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/conversion_spec.rb | Ruby | mit | 48 | master | 1,865 | describe "Parsi::Date.jd" do
it "constructs a date form given Chronological Julian day number" do
expect(Parsi::Date.jd(2456228)).to be == Parsi::Date.civil(1391, 8, 6)
expect(Parsi::Date.jd(2456229)).to be == Parsi::Date.civil(1391, 8, 7)
expect(Parsi::Date.jd(2456229)).to be == Parsi::Date.civil(1391, 8... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/constants_spec.rb | Ruby | mit | 48 | master | 1,567 | # encoding: utf-8
describe "Date constants" do
it "defines MONTHNAMES" do
expect(Parsi::Date::MONTHNAMES).to be ==
[nil] + %w(فروردین اردیبهشت خرداد تیر مرداد شهریور مهر آبان آذر دی بهمن اسفند)
end
it "defines EN_MONTHNAMES" do
expect(Parsi::Date::EN_MONTHNAMES).to be ==
[nil] + %w(farvardin ... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/add_month_spec.rb | Ruby | mit | 48 | master | 1,104 | describe "Parsi::Date#>>" do
it "adds the number of months to a Parsi::Date" do
expect(Parsi::Date.civil(1391, 2, 27) >> 10).to be == Parsi::Date.civil(1391, 12, 27)
expect(Parsi::Date.civil(1403, 11, 30) >> 1).to be == Parsi::Date.civil(1403, 12, 30)
end
it "sets the day to the last day of a month if th... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/accessor_spec.rb | Ruby | mit | 48 | master | 2,132 | describe "Parsi::Date#ajd" do
it "determines the Astronomical Julian day" do
expect(Parsi::Date.civil(1391, 8, 6).ajd).to be == Rational(4912455, 2)
expect(Parsi::Date.civil(1403, 12, 30).ajd).to be == Rational(4921509, 2)
end
end
describe "Parsi::Date#amjd" do
it "determines the Astronomical Modified Ju... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/construction_spec.rb | Ruby | mit | 48 | master | 2,722 | describe Parsi::Date do
context "civil" do
it "constructs a date with arguments" do
expect { Parsi::Date.civil 1391, 8, 6 }.to_not raise_error
expect { Parsi::Date.civil 1391, 12, 30 }.to_not raise_error # 1391 is a leap year
end
it "doesn't construct dates for invalid arguments" do
exp... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/leap_spec.rb | Ruby | mit | 48 | master | 592 | describe "Parsi::Date#leap?" do
it "returns true if a year is a leap year in the Parsi (Jalali) calendar" do
expect(Parsi::Date.leap?(1387)).to be true
expect(Parsi::Date.leap?(1391)).to be true
expect(Parsi::Date.leap?(1395)).to be true
expect(Parsi::Date.leap?(1403)).to be true
end
it "returns ... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/step_spec.rb | Ruby | mit | 48 | master | 1,050 | describe "Parsi::Date#step" do
it "steps forward in time" do
ds = Parsi::Date.civil(1391, 10, 11)
de = Parsi::Date.civil(1391, 9, 29)
count = 0
de.step(ds) do |d|
expect(d).to be <= ds
expect(d).to be >= de
count += 1
end
expect(count).to be == 13
count = 0
de.step(... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/comp_spec.rb | Ruby | mit | 48 | master | 1,152 | require 'date'
describe "Parsi::Date#<=>" do
it "returns 0 when two dates are equal" do
expect(Parsi::Date.civil(1391, 4, 6) <=> Parsi::Date.civil(1391, 4, 6)).to be == 0
expect(Parsi::Date.civil(1391, 4, 6) <=> Date.civil(2012, 6, 26)).to be == 0
end
it "returns -1 when self is less than another date" ... |
github | hzamani/parsi-date | https://github.com/hzamani/parsi-date | spec/parsi-date/add_spec.rb | Ruby | mit | 48 | master | 1,080 | describe "Parsi::Date#+" do
it "adds the number of days to a Parsi::Date" do
expect(Parsi::Date.civil(1391, 2, 27) + 10).to be == Parsi::Date.civil(1391, 3, 6)
expect(Parsi::Date.civil(1403, 12, 29) + 1).to be == Parsi::Date.civil(1403, 12, 30)
expect(Parsi::Date.civil(1403, 12, 30) + 1).to be == Parsi::D... |
github | shuber/validates_as_hostname_label | https://github.com/shuber/validates_as_hostname_label | validates_as_hostname_label.gemspec | Ruby | mit | 48 | master | 729 | Gem::Specification.new do |s|
s.name = 'validates_as_hostname_label'
s.version = '1.1.2'
s.date = '2014-03-05'
s.summary = 'Checks for valid hostname labels'
s.description = 'Checks for valid hostname labels'
s.author = 'Sean Huber'
s.email = 'shuber@huberry.com'
s.homepage = 'http://gi... |
github | shuber/validates_as_hostname_label | https://github.com/shuber/validates_as_hostname_label | Rakefile | Ruby | mit | 48 | master | 630 | require 'rake'
require 'rake/testtask'
require 'rdoc/task'
desc 'Default: run the validates_as_hostname_label tests'
task :default => :test
desc 'Test the validates_as_hostname_label gem/plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/*_test.rb'
t.verbose = true
end
desc 'Generate d... |
github | shuber/validates_as_hostname_label | https://github.com/shuber/validates_as_hostname_label | lib/validates_as_hostname_label.rb | Ruby | mit | 48 | master | 3,126 | require 'active_record'
require 'active_support/core_ext/object/with_options'
# Adds ActiveRecord validation for hostname labels
module ValidatesAsHostnameLabel
# A hash of default options to use when calling <tt>validates_as_hostname_label</tt>.
#
# Defaults:
#
# :allow_blank => false
# :allow... |
github | shuber/validates_as_hostname_label | https://github.com/shuber/validates_as_hostname_label | test/validates_as_hostname_label_test.rb | Ruby | mit | 48 | master | 4,927 | require 'rubygems'
require 'sqlite3'
require 'test/unit'
require File.dirname(__FILE__) + '/../lib/validates_as_hostname_label'
I18n.enforce_available_locales = false
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:'
class Account < ActiveRecord::Base
validates_as_hostname_labe... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | acts_as_scribe.gemspec | Ruby | mit | 48 | master | 1,655 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{acts_as_scribe}
s.version = "0.1.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Linking Paths", "Aitor Garc\303\255a", "Roberto Salicio"]
s.date = %q{2009-02-24}
s.... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | Rakefile | Ruby | mit | 48 | master | 1,611 | require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |s|
s.name = "acts_as_scribe"
s.summary = %Q{A simple plugin that allows to keep track of the users activity. Common uses could be user's wall, public timeline portlets, etc...}
s.email = "aitor@linkingpaths.com"
s.homepage = "http://gith... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | features/support/env.rb | Ruby | mit | 48 | master | 527 | require 'rubygems'
gem 'activerecord'
require 'active_record'
require 'factory_girl'
require 'redgreen'
require 'spec'
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
require 'acts_as_scribe'
require 'activity'
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
load(File.d... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | features/steps/scribe_steps.rb | Ruby | mit | 48 | master | 449 | Given /^I'm a user$/ do
@me = Factory :user
end
When /^I create a membership$/ do
@creating_membership = lambda do
@membership = Factory :membership, :user => @me
end
end
Then /^a new activity should be reported$/ do
@creating_membership.should change(Activity, :count).by(1)
end
Then /^the activity shoul... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | spec/spec_helper.rb | Ruby | mit | 48 | master | 419 | require 'rubygems'
gem 'activerecord'
require 'active_record'
require 'factory_girl'
require 'spec'
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
require 'acts_as_scribe'
require 'activity'
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
load(File.dirname(__FILE__) + "/s... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | spec/models.rb | Ruby | mit | 48 | master | 476 | class Post < ActiveRecord::Base
belongs_to :author, :class_name => "User"
record_activity_of :author, :if => Proc.new { |post| post.private == false }
end
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :group
record_activity_of :user, :actions => [:create, :update, :destroy]
end
class Gr... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | spec/schema.rb | Ruby | mit | 48 | master | 503 | ActiveRecord::Schema.define(:version => 1) do
create_table :activities do |t|
t.integer :user_id
t.string :action
t.integer :item_id
t.string :item_type
t.timestamps
end
create_table :users do |t|
t.string :login
end
create_table :groups do |t|
t.string :name
end
create_tab... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | spec/factories.rb | Ruby | mit | 48 | master | 324 | Factory.define :user do |user|
end
Factory.define :group do |group|
end
Factory.define :activity do |activity|
activity.association :user
end
Factory.define :membership do |membership|
membership.association :user
end
Factory.define :post do |post|
post.private false
post.association :author, :factory => :user
... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | spec/models/activity_spec.rb | Ruby | mit | 48 | master | 2,450 | require File.dirname(__FILE__) + '/../spec_helper'
describe "Activity" do
describe "when creating an instance of a model with a actor != user" do
before do
@p = Factory :post
@act = Activity.last
end
it "should find the created activity by the user" do
@act.user.should == @p.author
... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | generators/acts_as_scribe_migration/acts_as_scribe_migration_generator.rb | Ruby | mit | 48 | master | 224 | class ActsAsScribeMigrationGenerator < Rails::Generator::Base
def manifest
record do |m|
m.migration_template 'migration.rb', 'db/migrate'
end
end
def file_name
"acts_as_scribe_migration"
end
end |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | generators/acts_as_scribe_migration/templates/migration.rb | Ruby | mit | 48 | master | 396 | class ActsAsScribeMigration < ActiveRecord::Migration
def self.up
create_table :activities do |t|
t.integer :user_id
t.string :action
t.integer :item_id
t.string :item_type
t.timestamps
end
add_index :activities, [:item_type, :item_id]
end
def self.down
remove_ind... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | lib/scribe.rb | Ruby | mit | 48 | master | 1,583 | module LinkingPaths
module Acts #:nodoc:
module Scribe #:nodoc:
def self.included(base) # :nodoc:
base.extend ClassMethods
end
module ClassMethods
activity_options ||= {}
def record_activity_of(actor, options = {})
include_scribe_instance_methods {
... |
github | linkingpaths/acts_as_scribe | https://github.com/linkingpaths/acts_as_scribe | lib/activity.rb | Ruby | mit | 48 | master | 1,102 | class Activity < ActiveRecord::Base
named_scope :by_user, lambda { |users|
{ :conditions => { :user_id => users}}
}
named_scope :by_action, lambda { |action|
{ :conditions => { :action => action.to_s }}
}
named_scope :by_item, lambda { |item|
{ :conditions => { :item_type => item.class.name, ... |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | application.rb | Ruby | mit | 47 | master | 2,301 | require 'rubygems'
require 'sinatra'
require 'environment'
configure do
set :views, "#{File.dirname(__FILE__)}/views"
set :authorization_realm, "Protected"
end
error do
e = request.env['sinatra.error']
Kernel.puts e.backtrace.join("\n")
'Application error'
end
helpers do
include Merb::PaginationHelper
... |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | Rakefile | Ruby | mit | 47 | master | 2,706 | require 'spec/rake/spectask'
task :default => :test
task :test => :spec
if !defined?(Spec)
puts "spec targets require RSpec"
else
desc "Run all examples"
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_files = FileList['spec/**/*.rb']
t.spec_opts = ['-cfs']
end
end
namespace :db do
desc 'Auto-migrat... |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | config.ru | Ruby | mit | 47 | master | 226 | require 'application'
set :run, false
set :environment, :production
FileUtils.mkdir_p 'log' unless File.exists?('log')
log = File.new("log/sinatra.log", "a")
$stdout.reopen(log)
$stderr.reopen(log)
run Sinatra::Application |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | environment.rb | Ruby | mit | 47 | master | 1,678 | require 'rubygems'
require 'dm-core'
require 'dm-validations'
require 'dm-aggregates'
require 'dm-is-searchable'
require 'dm-sphinx-adapter'
require 'dm-timestamps'
require 'dm-is-paginated'
require 'merb-pagination'
require 'haml'
require 'ostruct'
require 'columbus'
require 'feedzirra'
require 'columbus'
require 'si... |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | lib/feed.rb | Ruby | mit | 47 | master | 3,071 | class Feed
include DataMapper::Resource
ATTR_MAP = {
:title => :title,
:url => :url,
:feed_url => :feed_url,
:etag => :etag
}
property :id, Serial
property :title, String, :length => 255
propert... |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | lib/entry.rb | Ruby | mit | 47 | master | 1,132 | class Entry
include DataMapper::Resource
ATTR_MAP = {
:title => :title,
:url => :url,
:author => :author,
:summary => :summary,
:content => :content,
:categories => :categories,
:published... |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | spec/application_spec.rb | Ruby | mit | 47 | master | 5,742 | require "#{File.dirname(__FILE__)}/spec_helper"
describe 'Application' do
include Rack::Test::Methods
def app
Sinatra::Application.new
end
before(:each) do
Feed.all.destroy!
Entry.all.destroy!
@feed = Factory(:feed)
@entry = Factory(:entry)
end
context 'home page' do
specify "sho... |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | spec/entry_spec.rb | Ruby | mit | 47 | master | 1,623 | require "#{File.dirname(__FILE__)}/spec_helper"
describe 'Entry' do
before(:each) do
Entry.all.destroy!
@entry = Factory.build(:entry)
@feed = Factory(:feed)
end
specify 'should be valid' do
@entry.should be_valid
end
context 'validations' do
specify 'should require a title' do
@e... |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | spec/factories.rb | Ruby | mit | 47 | master | 536 | require 'factory_girl'
Factory.define :feed do |f|
f.title 'zerosum dirt(nap) - Home'
f.url 'http://blog.zerosum.org/'
f.feed_url 'http://feeds2.feedburner.com/ZerosumDirtnap'
f.created_at Time.now
f.updated_at Time.now
f.approved true
end
Factory.define :entry do |f|
f.title 'Blog E... |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | spec/spec_helper.rb | Ruby | mit | 47 | master | 602 | require 'rubygems'
require 'sinatra'
require 'spec'
require 'spec/interop/test'
require 'rack/test'
require 'rspec_hpricot_matchers'
# set test environment
set :environment, :test
set :run, false
set :raise_errors, true
set :logging, false
require 'application'
require File.dirname(__FILE__) + '/factories'
# establi... |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | spec/feed_spec.rb | Ruby | mit | 47 | master | 3,227 | require "#{File.dirname(__FILE__)}/spec_helper"
describe 'Feed' do
before(:each) do
Feed.all.destroy!
Entry.all.destroy!
@feed = Factory.build(:feed, :approved => false)
end
specify 'should be valid' do
@feed.stub!(:check_remote_feed).and_return(true)
@feed.should be_valid
end
specify '... |
github | zapnap/mogofeed | https://github.com/zapnap/mogofeed | views/feed.builder | Ruby | mit | 47 | master | 673 | xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
xml.title SiteConfig.title
xml.id SiteConfig.url_base
xml.updated @entries.first.created_at.rfc3339 unless @entries.empty?
xml.author { xml.name SiteConfig.title }
@entries.each do |entry|
xml.entry do
xml.title entry.title
x... |
github | denko-rb/denko | https://github.com/denko-rb/denko | Rakefile | Ruby | mit | 48 | master | 491 | #!/usr/bin/env ruby
require "bundler/gem_tasks"
require 'rake/testtask'
require 'yard'
task :default => [:test]
Rake::TestTask.new do |t|
t.libs << "lib"
t.libs << "test"
t.warning = false
t.test_files = FileList['test/**/*_test.rb']
end
# YARD documentation task
YARD::Rake::YardocTask.new(:yard) do |t|
t.f... |
github | denko-rb/denko | https://github.com/denko-rb/denko | denko.gemspec | Ruby | mit | 48 | master | 2,412 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/denko/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["vickash, Austinbv"]
gem.email = ["mail@vickash.com"]
gem.description = %q{Electronics programming in Ruby}
gem.summary = %q{Use GPIO, PWM, I2C, SPI, and mor... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/digital_io/relay.rb | Ruby | mit | 48 | master | 366 | #
# Use Relays to work with higher voltage circuits. This example
# closes and opens a relay to send a 500ms pulse on a 12V control circuit.
#
require 'bundler/setup'
require 'denko'
PIN = 6
board = Denko::Board.new(Denko::Connection::Serial.new)
relay = Denko::DigitalIO::Relay.new(board: board, pin: PIN)
relay.clos... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/digital_io/button.rb | Ruby | mit | 48 | master | 452 | #
# Simple button example.
#
require 'bundler/setup'
require 'denko'
PIN = 3
board = Denko::Board.new(Denko::Connection::Serial.new)
button = Denko::DigitalIO::Button.new board: board,
pin: PIN,
mode: :input_pullup
button.up { puts "But... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/digital_io/rotary_encoder.rb | Ruby | mit | 48 | master | 1,105 | #
# KY-040 (30 detent) rotary encoder on a microcontroller, listener at 1ms.
#
# WARNING: This method is not precise and may miss steps. Don't use for anything
# that requires all steps to be read for exact positioning or high speed.
#
require 'bundler/setup'
require 'denko'
PIN_A = 4
PIN_B = 5
board = Denko::Board.n... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/pulse_io/ir_output.rb | Ruby | mit | 48 | master | 2,505 | #
# Test of the IROutput (infrared transmitter) class.
# The specific NEC code is one taken from the Arduino example:
# https://github.com/Arduino-IRremote/Arduino-IRremote/tree/master/examples/SendDemo
#
# To test your emitter works, flash the recieve sketch on a second board:
# https://github.com/Arduino-IRremote/Ard... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/pulse_io/pwm_output.rb | Ruby | mit | 48 | master | 787 | #
# PWM (pulse width modulation) output demo.
# Frequency and resolution are configurable (only on ESP32 and PiBoard/Linux for now).
# Capture output with logic analyzer or oscilloscope to verify accuracy.
#
require 'bundler/setup'
require 'denko'
PIN = 2
board = Denko::Board.new(Denko::Connection::Serial.new)
pwm = ... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/pulse_io/buzzer.rb | Ruby | mit | 48 | master | 779 | #
# Example of playing a melody on a piezoelectric buzzer.
#
require 'bundler/setup'
require 'denko'
PIN = 9
board = Denko::Board.new(Denko::Connection::Serial.new)
buzzer = Denko::PulseIO::Buzzer.new(board: board, pin: PIN)
C4 = 262
D4 = 294
E4 = 330
notes = [
[E4, 1], [D4, 1], [C4, 1], [D4, 1], [E4, 1... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/i2c/search.rb | Ruby | mit | 48 | master | 1,039 | #
# Example that shows the default I2C bus pins, and addresses of any
# devices connected to the bus.
#
require 'bundler/setup'
require 'denko'
board = Denko::Board.new(Denko::Connection::Serial.new)
# If board has a map, show the pins to the user.
if board.map
puts "Detected board: #{board.name}"
sda = board.map... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/uart/bit_bang_demo.rb | Ruby | mit | 48 | master | 917 | #
# Bit-bang UART is only used on the Arduino UNO / ATmega328p, because it has no
# extra hardware UARTs. This also makes a self-loopback test impossible. Connect a
# second board (Arduino Mega) and use its UART1 to verify bit-bang works on the Uno.
#
require 'bundler/setup'
require 'denko'
uno = Denko::Board.new(Den... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/uart/board_passthrough.rb | Ruby | mit | 48 | master | 1,591 | #
# Example using one board's UART as the transport for a second board, also running Denko.
#
# For this example, board1 (direct) is an Arduino Mega. board2 (passthrough) is an Uno,
# running Denko, with its UART pins (0, 1) connected to the Mega's UART1 pins (18, 19)
#
# This isn't 100% reliable. The Rx buffer on the ... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/uart/hardware_loopback.rb | Ruby | mit | 48 | master | 324 | #
# Write to Tx pin of hardware UART1 and read data back on its Rx pin.
#
require 'bundler/setup'
require 'denko'
board = Denko::Board.new(Denko::Connection::Serial.new)
uart = Denko::UART::Hardware.new(board: board, index: 1, baud: 31250)
uart.write("Hello World!\nBye World!\n")
sleep 1
puts uart.gets
puts uart.g... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/rtc/ds3231.rb | Ruby | mit | 48 | master | 682 | #
# D3231 real-time-clock over I2C. Set time and read back every 5 seconds.
#
require 'bundler/setup'
require 'denko'
board = Denko::Board.new(Denko::Connection::Serial.new)
i2c = Denko::I2C::Bus.new(board: board) # address: 0x68 default
# Tell the bus to search for devices.
i2c.search
if i2c.found_devices.empty?
... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/one_wire/search.rb | Ruby | mit | 48 | master | 905 | #
# Search a 1-Wire bus.
#
require 'bundler/setup'
require 'denko'
PIN = 4
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::OneWire::Bus.new(board: board, pin: PIN)
# Call #device_present to reset the bus and return presence pulse as a boolean.
if bus.device_present?
puts "Devices present o... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/tm1637.rb | Ruby | mit | 48 | master | 976 | #
# TM1637 is 4 seven-segment LEDS, plus a colon in the middle.
#
require 'bundler/setup'
require 'denko'
board = Denko::Board.new(Denko::Connection::Serial.new)
tm1637 = Denko::LED::TM1637.new(board: board, pins: {clk: 4, dio: 5}, rotate: true)
# Digits are instances of LED::SevenSegment
# Access them directly
tm16... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/seven_segment_char_echo.rb | Ruby | mit | 48 | master | 442 | #
# Echo pressed keys to a seven segment LED.
#
require 'bundler/setup'
require 'denko'
PINS = { cathode: 10, a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9 }
board = Denko::Board.new(Denko::Connection::Serial.new)
ssd = Denko::LED::SevenSegment.new board: board,
pins: PINS
# Turn ... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/tm1652.rb | Ruby | mit | 48 | master | 1,115 | #
# TM1637 is 4 seven-segment LEDS, plus a colon in the middle.
#
require 'bundler/setup'
require 'denko'
board = Denko::Board.new(Denko::Connection::Serial.new)
uart = Denko::UART::Hardware.new(board: board, index: 1, baud: 19200, config: "8O1")
tm1652 = Denko::LED::TM1652.new(board: board, uart: uart)
# digits a... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/apa102_fade.rb | Ruby | mit | 48 | master | 993 | #
# Fade test for APA102 LED strip.
#
require 'bundler/setup'
require 'denko'
RED = [255, 0, 0]
GREEN = [0, 255, 0]
BLUE = [0, 0, 255]
WHITE = [255, 255, 255]
COLORS = [RED, GREEN, BLUE, WHITE]
PIXELS = 4
# Get all the brightness values as an array.
brightness_steps = (0..31).to_a + (1..30).to_a.reverse
# Use... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/builtin_fade.rb | Ruby | mit | 48 | master | 362 | #
# Blink example for standard built-in LEDs named :LED_BUILTIN
#
require 'bundler/setup'
require 'denko'
PIN = :LED_BUILTIN
board = Denko::Board.new(Denko::Connection::Serial.new)
led = Denko::LED.new(board: board, pin: PIN)
min = 0
max = 100
values = (min..max).to_a + (min..max-1).to_a.reverse
values.cycle do |va... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/rgb_led.rb | Ruby | mit | 48 | master | 732 | #
# A standard 3 pin RGB LED (not single pin addressable), on 3 PWM pins.
#
require 'bundler/setup'
require 'denko'
RED_PIN = 11
GREEN_PIN = 10
BLUE_PIN = 9
board = Denko::Board.new(Denko::Connection::Serial.new)
rgb_led = Denko::LED::RGB.new board: board,
pins: {red: RED_PIN, green:... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/apa102_bounce.rb | Ruby | mit | 48 | master | 769 | #
# Walk a single pixel along the length of an APA102 strip and back,
# changing color each time it returns to position 0.
#
require 'bundler/setup'
require 'denko'
RED = [255, 0, 0]
GREEN = [0, 255, 0]
BLUE = [0, 0, 255]
WHITE = [255, 255, 255]
COLORS = [RED, GREEN, BLUE, WHITE]
PIXELS = 8
# Move along the st... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/tm1638.rb | Ruby | mit | 48 | master | 880 | #
# TM1637 is 4 seven-segment LEDS, plus a colon in the middle.
#
require 'bundler/setup'
require 'denko'
board = Denko::Board.new(Denko::Connection::Serial.new)
tm1638 = Denko::LED::TM1638.new(board: board, pins: {clk: 4, dio: 5, stb: 6})
# Digits are instances of LED::SevenSegment
# Access them directly
tm1638.dig... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/ws2812_builtin_blink.rb | Ruby | mit | 48 | master | 456 | #
# Blink example for the LOLIN ESP32 S3 or C3, or any board where
# :LED_BUILTIN is the data pin for a single on-board WS2812.
#
require 'bundler/setup'
require 'denko'
PIN = :LED_BUILTIN
WHITE = [255, 255, 255]
OFF = [0, 0, 0]
board = Denko::Board.new(Denko::Connection::Serial.new)
strip = Denko::LED::WS2812.ne... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/seven_segment_spi.rb | Ruby | mit | 48 | master | 607 | #
# Multiple LED::SevenSegment though series registers, like a 74HC595.
#
require 'bundler/setup'
require 'denko'
SELECT_PIN = 53
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::SPI::Bus.new(board: board, index: 0)
ssd_array = Denko::LED::SevenSegmentSPI.new(bus: bus, pin: SELECT_PIN, d... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/builtin_blink.rb | Ruby | mit | 48 | master | 250 | #
# Blink example for standard built-in LEDs named :LED_BUILTIN
#
require 'bundler/setup'
require 'denko'
PIN = :LED_BUILTIN
board = Denko::Board.new(Denko::Connection::Serial.new)
led = Denko::LED.new(board: board, pin: PIN)
led.blink 0.5
sleep |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/ws2812_fade.rb | Ruby | mit | 48 | master | 842 | #
# Fade colors along a WS2812, and over time.
#
require 'bundler/setup'
require 'denko'
PIN = 4
PIXELS = 8
board = Denko::Board.new(Denko::Connection::Serial.new)
strip = Denko::LED::WS2812.new(board: board, pin: PIN, length: PIXELS)
min = 0
max = 255
gap = 5
values = (min..max).step(gap).to_a + (min..max-gap).s... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/led/ws2812_bounce.rb | Ruby | mit | 48 | master | 613 | #
# Walk a pixel along a WS2812 strip and back, changing color each loop.
#
require 'bundler/setup'
require 'denko'
PIN = 4
PIXELS = 8
RED = [255, 0, 0]
GREEN = [0, 255, 0]
BLUE = [0, 0, 255]
WHITE = [255, 255, 255]
COLORS = [RED, GREEN, BLUE, WHITE]
positions = (0..PIXELS-1).to_a + (1..PIXELS-2).to_a.reve... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/qmp6988.rb | Ruby | mit | 48 | master | 1,452 | #
# Example using QMP6988 sensor over I2C, for air temperature and pressure.
#
require 'bundler/setup'
require 'denko'
require_relative 'neat_tph_readings'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
sensor = Denko::Sensor::QMP6988.new(bus: bus) # address: 0x70 d... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/hcsr04.rb | Ruby | mit | 48 | master | 358 | #
# Example of reading an HC-SR04 ultrasonic sensor.
#
require 'bundler/setup'
require 'denko'
TRIGGER_PIN = 6
ECHO_PIN = 7
board = Denko::Board.new(Denko::Connection::Serial.new)
hcsr04 = Denko::Sensor::HCSR04.new(board: board, pins: {trigger: TRIGGER_PIN, echo: ECHO_PIN})
hcsr04.poll(0.50) do |distance|
puts ... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/bmp180.rb | Ruby | mit | 48 | master | 813 | #
# BMP180 sensor over I2C, for temperature and pressure.
#
require 'bundler/setup'
require 'denko'
require_relative 'neat_tph_readings'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
sensor = Denko::Sensor::BMP180.new(bus: bus) # address: 0x77 default
# Enable ove... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/alspt19.rb | Ruby | mit | 48 | master | 404 | #
# ALS PT19 light sensor.
#
require 'bundler/setup'
require 'denko'
PIN = :A0
board = Denko::Board.new(Denko::Connection::Serial.new)
sensor = Denko::Sensor::ALSPT19.new(board: board, pin: PIN, vcc: 5.0)
# Enable smoothing on the input using the last 16 values.
sensor.smoothing = true
sensor.smoothing_size = 8
sens... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/temt6000.rb | Ruby | mit | 48 | master | 406 | #
# TEMT 6000 light sensor.
#
require 'bundler/setup'
require 'denko'
PIN = :A1
board = Denko::Board.new(Denko::Connection::Serial.new)
sensor = Denko::Sensor::TEMT6000.new(board: board, pin: PIN, vcc: 5.0)
# Enable smoothing on the input using the last 16 values.
sensor.smoothing = true
sensor.smoothing_size = 8
se... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/hdc1080.rb | Ruby | mit | 48 | master | 1,582 | #
# HDC1080 sensor over I2C, for temperature and humidity.
#
require 'bundler/setup'
require 'denko'
require_relative 'neat_tph_readings'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
sensor = Denko::Sensor::HDC1080.new(bus: bus) # address: 0x40 default
# Show the... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/sht3x.rb | Ruby | mit | 48 | master | 762 | #
# SHT30/31/35 sensor over I2C, for temperature and humidity.
#
require 'bundler/setup'
require 'denko'
require_relative 'neat_tph_readings'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
sensor = Denko::Sensor::SHT3X.new(bus: bus) # address: 0x44 default
# Heater... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/sht4x.rb | Ruby | mit | 48 | master | 638 | #
# SHT40 sensor over I2C, for temperature and humidity.
#
require 'bundler/setup'
require 'denko'
require_relative 'neat_tph_readings'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
sensor = Denko::Sensor::SHT4X.new(bus: bus) # address: 0x44 default
# Read and pri... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/tsl2561.rb | Ruby | mit | 48 | master | 827 | #
# TSL2561 lgiht sensor.
#
require 'bundler/setup'
require 'denko'
require_relative 'neat_tph_readings'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
sensor = Denko::Sensor::TSL2561.new(bus: bus) # address: 0x39 default
# Configurable integration time (poll with ... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/vl53l0x.rb | Ruby | mit | 48 | master | 461 | #
# VL53L0X sensor over I2C to measure distance.
#
require 'bundler/setup'
require 'denko'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
sensor = Denko::Sensor::VL53L0X.new(bus: bus) # address: 0x29 default
# Correct for my sensor always being off by +52mm.
# Adju... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/ds18b20.rb | Ruby | mit | 48 | master | 1,373 | #
# Example of how to use the Dallas DS18B20 temperature sensor.
#
require 'bundler/setup'
require 'denko'
PIN = 4
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::OneWire::Bus.new(board: board, pin: PIN)
unless bus.device_present?
puts "No devices present on bus... Quitting..."
return
en... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/dht.rb | Ruby | mit | 48 | master | 650 | #
# DHT sensor class for DHT 11 and DHT 22 sensors.
#
require 'bundler/setup'
require 'denko'
require_relative 'neat_tph_readings'
PIN = 5
board = Denko::Board.new(Denko::Connection::Serial.new)
sensor = Denko::Sensor::DHT.new(board: board, pin: PIN)
sensor.read
if sensor.temperature
puts "Temperature unit hel... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/htu31d.rb | Ruby | mit | 48 | master | 855 | #
# HTU31D sensor over I2C, for temperature and humidity.
#
require 'bundler/setup'
require 'denko'
require_relative 'neat_tph_readings'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
sensor = Denko::Sensor::HTU31D.new(bus: bus) # address: 0x40 default
# Get and se... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/generic_pir.rb | Ruby | mit | 48 | master | 824 | #
# Example using a PIR motion sensor. Tested with AS312 and HC-SR501 sensors.
#
# General notes:
# - Both sensors have a few seconds "dead time" after "motion stop" (logical 0), where further
# motion will not trigger "motion start" (logical 1).
#
# HC-SR501 notes:
# - Needs some time to warm up and start work... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/neat_tph_readings.rb | Ruby | mit | 48 | master | 856 | #
# This helper method can be used in temp/pressure/humidity sensor examples.
# Give a hash with readings as float values and it prints them neatly.
#
def print_tph_reading(reading)
elements = []
# Temperature
if reading[:temperature]
formatted_temp = reading[:temperature].to_f.round(2).to_s.ljust(5, '0')
... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/bme280.rb | Ruby | mit | 48 | master | 1,072 | #
# BME280 sensor over I2C, for temperature, pressure and humidity.
#
require 'bundler/setup'
require 'denko'
require_relative 'neat_tph_readings'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
sensor = Denko::Sensor::BME280.new(bus: bus) # address: 0x76 default
# Us... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/jsnsr04t.rb | Ruby | mit | 48 | master | 379 | #
# Example of reading a JSN-SR04T ultrasonic sensor, in mode 2.
#
require 'bundler/setup'
require 'denko'
board = Denko::Board.new(Denko::Connection::Serial.new)
uart = Denko::UART::Hardware.new(board: board, index: 1, baud: 9600)
ultrasonic = Denko::Sensor::JSNSR04T.new(board: board, uart: uart)
ultrasonic.poll(1) ... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/rcwl9620.rb | Ruby | mit | 48 | master | 342 | #
# RCWL-9620 sensor over I2C to measure distance.
#
require 'bundler/setup'
require 'denko'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
sensor = Denko::Sensor::RCWL9620.new(bus: bus) # address: 0x57 default
sensor.poll(1) do |distance|
puts "Distance is #{dis... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/aht.rb | Ruby | mit | 48 | master | 583 | #
# AHT10, AHT15, AHT20, AHT21, AHT25 and AHT30 sensors over I2C, for temperature and humidity.
#
require 'bundler/setup'
require 'denko'
require_relative 'neat_tph_readings'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
# sensor = Denko::Sensor::AHT1X.new(bus: bus... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/sensor/htu21d.rb | Ruby | mit | 48 | master | 1,240 | #
# HTU21D sensor over I2C, for temperature and humidity.
#
require 'bundler/setup'
require 'denko'
require_relative 'neat_tph_readings'
board = Denko::Board.new(Denko::Connection::Serial.new)
bus = Denko::I2C::Bus.new(board: board)
htu21d = Denko::Sensor::HTU21D.new(bus: bus) # address: 0x40 default
# Get and se... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/motor/servo.rb | Ruby | mit | 48 | master | 431 | #
# This is an example of how to use the servo class
#
require 'bundler/setup'
require 'denko'
PIN = 9
board = Denko::Board.new(Denko::Connection::Serial.new)
servo = Denko::Motor::Servo.new(board: board, pin: PIN)
# Add different angles (in degrees) to the array below to try out your servo.
# Note: Some servos ma... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/motor/l298.rb | Ruby | mit | 48 | master | 838 | #
# Drive a DC motor with the L298 H-Bridge driver.
#
require 'bundler/setup'
require 'denko'
board = Denko::Board.new(Denko::Connection::Serial.new)
PINS = { direction1: 8, direction2: 9, enable: 10 }
# This is only 1 channel of the driver. Make a new object for each channel.
motor = Denko::Motor::L298.new(board: bo... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/motor/a3967.rb | Ruby | mit | 48 | master | 978 | #
# Use a stepper motor with the EasyDriver board: https://www.sparkfun.com/products/12779
#
require 'bundler/setup'
require 'denko'
PINS = { slp: 6, enable: 7, direction: 8, step: 10, ms1: 11, ms2: 12 }
board = Denko::Board.new(Denko::Connection::Serial.new)
stepper = Denko::Motor::A3967.new(board: board, pins: PINS... |
github | denko-rb/denko | https://github.com/denko-rb/denko | examples/advanced/ssd1306_time_temp_rh.rb | Ruby | mit | 48 | master | 1,172 | #
# This example polls an HTU21D (temp/humidity sensor) in the background.
# The main thread refreshes an SSD1306 OLED ~20 times per second,
# showing the latest temperature and humidity values, and current time.
# Both devices are conected to the same I2C bus.
#
require 'bundler/setup'
require 'denko'
board = Denko::... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.