(add-hook 'after-init-hook
(lambda ()
- (require 're-logic-defuns)
(require 're-repl-defuns)
- (require 're-math-defuns)
- (require 're-electronics-defuns)
- (require 're-unit-conversions)
- (require 're-plc-defuns)
- (require 're-refrigeration-defuns)
(require 're-howm-defuns)))
(add-to-list 'auto-mode-alist '("\\.keymap\\'" . c-mode))
+++ /dev/null
-;;; re-electronics-defuns.el -*- lexical-binding: t; -*-
-;; This file is not part of GNU Emacs
-
-;;; Code:
-
-(require 're-math-defuns)
-
-(defun eff-imp (r1 &optional r2)
- "Calculate the effective input impedance, given two resistances.
-For use in `amps->volts' and related."
- (inv (+ (inv r1) (inv r2))))
-
-(defun amps->volts (amps imp)
- "Calculate the voltage, given amperage and impedance.
-Multiplies the amperage by the effective impedance calculated
-with `eff-imp'."
- (* amps imp))
-
-(defun volts->amps (volts imp)
- "Calculate the amperage, given voltage and impedance.
-Divides the voltage by the effective impedance calculated with
-`eff-imp'."
- (/ volts imp))
-
-(provide 're-electronics-defuns)
-;;; re-electronics-defuns.el ends here
+++ /dev/null
-;;; re-logic-defuns.el -*- lexical-binding: t; -*-
-;; This file is not part of GNU Emacs
-
-;;; Code:
-
-(defmacro >0 (x)
- "Determine if x>0."
- `(> ,x 0))
-
-(defmacro <0 (x)
- "Determine if x<0."
- `(< ,x 0))
-
-(defmacro =0 (x)
- "Determine if x=0."
- `(= ,x 0))
-
-(provide 're-logic-defuns)
-;;; re-logic-defuns.el ends here
+++ /dev/null
-;;; re-math-defuns.el -*- lexical-binding: t; -*-
-;; This file is not part of GNU Emacs
-
-;;; Code:
-
-(defalias '^ 'expt)
-
-(defmacro square (x)
- "Calculate the square of a value."
- `(^ ,x 2))
-
-(defmacro cube (x)
- "Calculate the cube of a value."
- `(^ ,x 3))
-
-(defmacro inv (x)
- "Calculate the inverse of a value."
- `(/ 1
- (float ,x)))
-
-(defmacro E (number exponent)
- "Prefix Engineering notation.
-i.e. (E 5 3) == 5E3 == 5000"
- `(* ,number (^ 10 ,exponent)))
-
-(provide 're-math-defuns)
-;;; re-math-defuns.el ends here
+++ /dev/null
-;;; re-plc-defuns.el -*- lexical-binding: t; -*-
-;; This file is not part of GNU Emacs
-
-;;; Code:
-
-(require 're-electronics-defuns)
-
-(defvar *plc-resolution* 16)
-(defvar *plc-max-voltage* 10.0)
-
-(defun 16B () (setq *plc-resolution* 16
- *plc-max-voltage* 10.0))
-
-(defun 13B () (setq *plc-resolution* 13
- *plc-max-voltage* 10.0))
-
-(defalias 'P3K '16B)
-(defalias 'SLC '16B)
-(defalias 'P1K '13B)
-(defalias 'DL4 '13B)
-
-(defun max-counts (resolution)
- "Calculate the max count for a PLC analog, given card's bit-resolution."
- (1- (^ 2 resolution)))
-
-(defun volts->counts (vin)
- "Convert a voltage signal to a PLC count.
-Calculates a ratio of vin/vmax, then scales by `max-counts'."
- (* (/ vin *plc-max-voltage*) (max-counts *plc-resolution*)))
-
-(defun counts->volts (cin)
- "Convert a PLC count to a voltage.
-Calculates a ratio of cin/`max-counts', then multiplies by vmax."
- (* (/ cin (max-counts *plc-resolution*)) *plc-max-voltage*))
-
-(defun amps->counts (amps imp)
- "Convert a current signal to PLC Counts.
-Converts the amperage to a voltage using `amps->volts',then applies
- `volts->counts' to the resulting voltage,vmax, and resolution."
- (volts->counts *plc-max-voltage* (amps->volts amps imp) *plc-resolution*))
-
-(defun count-range (upper lower)
- "Given an upper and lower voltage, return the list of upper and lower PLC counts."
- (list (volts->counts upper) (volts->counts lower)))
-
-(defun volt-range (upper lower)
- "Given an upper and lower PLC count, return the list of upper and lower voltage."
- (list (counts->volts upper) (counts->volts lower)))
-
-(defun divisor (counts-max counts-min engineering-max engineering-min)
- "Calculate 1/slope given PLC Max/Min and Eng. Max/Min."
- (/ (float (- counts-max counts-min)) (- engineering-max engineering-min)))
-
-(defun offset (divisor engineering-min counts-min)
- "Calculate offset given Divisor and both minimums."
- (- engineering-min (/ counts-min divisor)))
-
-(defun count-scale (counts-max counts-min engineering-max engineering-min)
- "Calculate the divisor and offset, from counts and eng values."
- (let* ((div (divisor counts-max counts-min engineering-max engineering-min))
- (ofst (offset div engineering-min counts-min)))
- (list div ofst)))
-
-(defun scale (signal-max signal-min engineering-max engineering-min &optional impedance)
- "Calculate the divisor and offset, from signal and eng values.
-Current signal if `impedance' is not nil, otherwise voltage signal.
-Uses `count-range', which uses `*plc-resolution*' and `*plc-max-voltage*'
-variables."
- (let* ((rng (if impedance
- (count-range (amps->volts signal-max impedance)
- (amps->volts signal-min impedance))
- (count-range signal-max signal-min)))
- (counts-max (car rng))
- (counts-min (cadr rng)))
- (count-scale counts-max counts-min engineering-max engineering-min)))
-
-(defun final (counts divisor offset)
- "Calculate the scaled value of an input."
- (+ (/ counts divisor) offset))
-
-(defun input (scaled-value divisor offset)
- "Calculate the input counts from a scaled value."
- (* divisor (- scaled-value offset)))
-
-(provide 're-plc-defuns)
-;;; re-plc-defuns.el ends here
+++ /dev/null
-;;; re-refrigeration-defuns.el -*- lexical-binding: t; -*-
-;; This file is not part of GNU Emacs
-
-;;; Code:
-
-(require 're-math-defuns)
-(require 're-unit-conversions)
-
-;; Cooling
-(defun cfm-circ (fpm radius)
- "Calculate the CFM of a circular duct.
-Inputs are feet/minute and radius (ft)."
- (* float-pi fpm (square radius)))
-
-(defun cfm-rect (fpm width height)
- "Calculate the CFM of a rectangular duct.
-Inputs are feet/minute, width (ft) and height (ft)."
- (* (float fpm) width height))
-
-(defun sat-water-press (temp)
- "Calculate the saturated water pressure at a temp (F)."
- (+ (E 1.82795 -2)
- (* temp (E 1.029904 -3))
- (* (^ temp 2) (E 2.579408 -5))
- (* (^ temp 3) (E 2.400493 -7))
- (* (^ temp 4) (E 8.100939 -10))
- (* (^ temp 5) (E 3.256805 -11))
- (* (^ temp 6) (E -1.001922 -13))
- (* (^ temp 7) (E 2.44161 -16))))
-
-(defun hum-press (humidity swp)
- "Calculate the Humidity-Pressure."
- (* (/ humidity 100.0) swp))
-
-(defun hum-ratio (humidity-pressure)
- "Calulate the humidity ratio.
-Takes humidity-pressure."
- (/ (* humidity-pressure 0.62198) (- 14.7 humidity-pressure)))
-
-(defun gn-water-per-lb (humidity temp)
- "Calculate the grains of water per lb of air.
-Takes humidity in %RH, and temp in F."
- (* 7000 (hum-ratio (hum-press humidity (sat-water-press temp)))))
-
-(provide 're-refrigeration-defuns)
-;;; re-refrigeration-defuns.el ends here
+++ /dev/null
-;;; re-unit-conversions.el -*- lexical-binding: t; -*-
-;; This file is not part of GNU Emacs
-
-;;; Code:
-
-(require 're-math-defuns)
-
-;; Leŋþ
-(defun mm->in (mm)
- "Convert milimeters to inches."
- (/ mm 25.4))
-
-(defun in->mm (in)
- "Convert inches to milimeters."
- (* in 25.4))
-
-;; Heat
-(defun k->c (tempk)
- "Convert degrees Kelvin to degrees Celsius."
- (- tempk 273.15))
-
-(defun c->k (tempc)
- "Convert degrees Celsius to degrees Kelvin."
- (+ tempc 273.15))
-
-(defun c->f (tempc)
- "Convert degrees Celsius to degrees Fahrenheit."
- (+ (* tempc 1.8) 32.0))
-
-(defun f->c (tempf)
- "Convert degrees Fahrenheit to degrees Celsius."
- (/ (- tempf 32.0) 1.8))
-
-(defun k->f (tempk)
- "Convert degrees Kelvin to degrees Fahrenheit.
-Applies `c->f' to `k->c'."
- (c->f (k->c tempk)))
-
-(defun f->k (tempf)
- "Convert degrees Fahrenheit to degrees Kelvin.
-Applies `c->k' to `f->c'."
- (c->k (f->c tempf)))
-
-;; Pressure
-(defun bar->psi (bar)
- "Convert bar to psi."
- (* 14.5 bar))
-
-(defun psi->bar (psi)
- "Convert psi to bar."
- (/ psi 14.5))
-
-(defun kpa->psi (kpa)
- "Convert kpa to psi."
- (* 6.89 kpa))
-
-(defun psi->kpa (psi)
- "Convert psi to kpa."
- (/ psi 6.89))
-
-(defun mmhg->psi (mmhg)
- "Convert mmhg to psi."
- (/ mmhg 51.71))
-
-(defun psi->mmhg (psi)
- "Convert psi to mmhg."
- (* 51.71 psi))
-
-(defun inhg->psi (inhg)
- "Convert inhg to psi."
- (mmhg->psi (in->mm inhg)))
-
-(defun psi->inhg (psi)
- "Convert psi to inhg."
- (mm->in (psi->mmhg psi)))
-
-;; Weight
-(defun g->oz (grams)
- "Convert grams to ounces."
- (/ grams 28.34))
-
-(defun oz->g (ounces)
- "Convert ounces to grams."
- (* ounces 28.34))
-
-(defun kg->lb (kilograms)
- "Convert kilograms to pounds."
- (* kilograms 2.2))
-
-(defun lb->kg (pounds)
- "Convert pounds to kilograms."
- (/ pounds 2.2))
-
-(provide 're-unit-conversions)
-;;; re-unit-conversions.el ends here